Skip to content

Commit a9add01

Browse files
committed
fix linking on macos
1 parent 5792e5f commit a9add01

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

source/backends/arm64.d

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ class BackendARM64 : CompilerBackend {
160160
linkCommand ~= format(" -l%s", lib);
161161
}
162162

163+
if (os == "osx") {
164+
linkCommand ~= " -lSystem -syslibroot `xcrun --sdk macosx --show-sdk-path`";
165+
}
166+
163167
if (useLibc) {
164168
if (os == "linux") {
165169
string[] possiblePaths = [
@@ -184,7 +188,7 @@ class BackendARM64 : CompilerBackend {
184188
}
185189
}
186190
else if (os == "osx") {
187-
linkCommand ~= " -lSystem -syslibroot `xcrun --sdk macosx --show-sdk-path`";
191+
// Always supported and enabled.
188192
}
189193
else {
190194
WarnNoInfo("Cannot use libc on operating system '%s'", os);

source/backends/x86_64.d

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ class BackendX86_64 : CompilerBackend {
201201
);
202202

203203
if (os == "osx") {
204-
linkCommand ~= " -ld_classic";
204+
linkCommand ~= " -platform_version macos 10.6 `xcrun --sdk macosx --show-sdk-version`";
205+
linkCommand ~= " -ld_classic -no_pie -e _main";
206+
linkCommand ~= " -lSystem -syslibroot `xcrun --sdk macosx --show-sdk-path`";
205207
}
206208

207209
foreach (ref lib ; link) {
@@ -235,7 +237,7 @@ class BackendX86_64 : CompilerBackend {
235237
}
236238
}
237239
else if (os == "osx") {
238-
linkCommand ~= " -syslibroot `xcrun --sdk macosx --show-sdk-path`";
240+
// Always supported and enabled.
239241
}
240242
else {
241243
WarnNoInfo("Cannot use libc on operating system '%s'", os);

0 commit comments

Comments
 (0)