Skip to content

Commit 5a214de

Browse files
committed
fix: set compiler flags for MacOS in the build script
The flags set in cargo config will be ignored if the `RUSTFLAGS` is set.
1 parent d368a28 commit 5a214de

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

.cargo/config.toml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,2 @@
1-
#
2-
# https://stackoverflow.com/questions/28124221/error-linking-with-cc-failed-exit-code-1
3-
#
4-
[target.aarch64-apple-darwin]
5-
rustflags = [
6-
"-C", "link-arg=-undefined",
7-
"-C", "link-arg=dynamic_lookup",
8-
]
9-
[target.x86_64-apple-darwin]
10-
rustflags = [
11-
"-C", "link-arg=-undefined",
12-
"-C", "link-arg=dynamic_lookup",
13-
]
14-
151
[env]
162
CACHE_DIR = { value = ".cache", relative = true }

build.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,11 @@ fn main() {
4343
// println!("cargo::rustc-cfg=nginx1_27_0");
4444
// }
4545
// }
46+
47+
// Generate required compiler flags
48+
if cfg!(target_os = "macos") {
49+
// https://stackoverflow.com/questions/28124221/error-linking-with-cc-failed-exit-code-1
50+
println!("cargo::rustc-link-arg=-undefined");
51+
println!("cargo::rustc-link-arg=dynamic_lookup");
52+
}
4653
}

0 commit comments

Comments
 (0)