@@ -9,6 +9,7 @@ project('mstrap',
9
9
]
10
10
)
11
11
12
+ cc = meson .get_compiler(' c' )
12
13
target_arch = host_machine .cpu_family()
13
14
target_system = host_machine .system()
14
15
target_triple = target_arch + ' -unknown-' + target_system
@@ -17,6 +18,7 @@ buildtype = get_option('buildtype')
17
18
is_darwin = target_system == ' darwin'
18
19
is_static = get_option (' default_library' ) == ' static'
19
20
is_static_libc = false
21
+ needs_macos_classic_linker = false
20
22
21
23
if target_system == ' linux'
22
24
target_cabi = meson .get_external_property(' target_triple_suffix' , ' gnu' )
@@ -34,9 +36,17 @@ elif target_system == 'darwin'
34
36
target_triple = macos_arch + ' -apple-macos' + macos_abi
35
37
add_global_arguments (' -target' , target_triple, language : ' c' , native : false )
36
38
add_global_link_arguments (' -target' , target_triple, language : ' c' , native : false )
39
+
40
+ # Use legacy linker with xcode 15+
41
+ xcode_version_output = run_command (find_program (' xcodebuild' ), ' -version' , check : true ).stdout()
42
+ xcode_version = xcode_version_output.split(' \n ' ).get(0 , '' ).replace(' Xcode' , '' ).strip()
43
+
44
+ if xcode_version.version_compare(' >=15.0' ) and cc.has_link_argument(' -Wl,-ld_classic' )
45
+ needs_macos_classic_linker = true
46
+ add_global_link_arguments (' -Wl,-ld_classic' , language : ' c' )
47
+ endif
37
48
endif
38
49
39
- cc = meson .get_compiler(' c' )
40
50
crystal = find_program (get_option (' crystal' ), required : true )
41
51
shards = find_program (get_option (' shards' ), required : true )
42
52
@@ -157,6 +167,10 @@ if is_static_libc
157
167
crystal_build_flags += [' --static' ]
158
168
endif
159
169
170
+ if needs_macos_classic_linker
171
+ crystal_build_flags += [' --link-flags=-Wl,-ld_classic' ]
172
+ endif
173
+
160
174
mstrap_build_cmd = [crystal, ' build' ] + crystal_build_flags + [' -o' , ' mstrap' , ' @INPUT@' ]
161
175
162
176
mstrap_o = custom_target (
0 commit comments