Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning: overriding the module target triple with x86_64-apple-macosx10.15.0 #281

Closed
yhara opened this issue Apr 21, 2021 · 6 comments · Fixed by #282 or #369
Closed

warning: overriding the module target triple with x86_64-apple-macosx10.15.0 #281

yhara opened this issue Apr 21, 2021 · 6 comments · Fixed by #282 or #369

Comments

@yhara
Copy link
Collaborator

yhara commented Apr 21, 2021

After #280, I got the following warning.

$ cargo run -- run examples/a.sk
   Compiling shiika v0.0.1 (/Users/yhara/Dropbox/proj/shiika)
    Finished dev [unoptimized + debuginfo] target(s) in 12.80s
     Running `/Users/yhara/tmp/shiika/debug/shiika run examples/a.sk`
[src/code_gen/mod.rs:59] &inkwell::targets::TargetMachine::get_default_triple() = TargetTriple("x86_64-apple-darwin19.6.0")
clang-9: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
warning: overriding the module target triple with x86_64-apple-macosx10.15.0 [-Woverride-module]
1 warning generated.
warning: overriding the module target triple with x86_64-apple-macosx10.15.0 [-Woverride-module]
1 warning generated.

The program itself works fine, but these warnings are a bit annoying.

@yhara
Copy link
Collaborator Author

yhara commented Apr 21, 2021

Why clang tries to "override" the target triple to macosx10.15.0 while get_default_triple returns darwin19.6.0?

$ clang --version
clang version 9.0.1
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm@9/bin

@yhara
Copy link
Collaborator Author

yhara commented Apr 21, 2021

@yhara
Copy link
Collaborator Author

yhara commented Apr 23, 2021

My guess is:

  • llvm@9 installed by homebrew is configured as "darwin" (= any of macOS, iOS, etc.)
  • clang detects it is running on "macosx"
  • the warning is shown

I found crystal-lang fixes this problem here. This is true until crystal runs on iOS or watchOS.

@yhara
Copy link
Collaborator Author

yhara commented Apr 24, 2021

Hmm, replace is not enough because .replace("darwin", "macosx") results in "x86_64-apple-macosx19.4.0", not "x86_64-apple-macosx10.15.0" (the version is wrong.)

yhara added a commit that referenced this issue Apr 25, 2021
by explicitly passing `-target`

refs #281
@yhara
Copy link
Collaborator Author

yhara commented Apr 25, 2021

Thanks to @LEA0317, we've found that clang computes "effective" target triple. That's why other commands like llvm-config --host-target or dsymutil --version just shows darwin and only clang shows macosx.

rustc reads special envvar for this issue.
rust-lang/rust#60235 (comment)

So there should be two ways to suppress this warning.

  1. Create a string "x86_64-apple-macosx19.4.0" somehow and use it for .bc's target triple.
  2. Explicitly specify target triple by clang's -target option.

But 1. is practically impossible because the clang's algorithm is pretty long and depends on heuristics. PR #282 fixes this issue by solution 2.

@yhara
Copy link
Collaborator Author

yhara commented Aug 3, 2022

Found one more case this warning appears.

[src/targets.rs:4] &inkwell::targets::TargetMachine::get_default_triple() = TargetTriple("x86_64-apple-darwin21.4.0")
[src/targets.rs:13] &s = "x86_64-apple-macosx12.3"
warning: overriding the module target triple with x86_64-apple-macosx12.3.0 [-Woverride-module]

mac-sys-info crate returns macosx12.3 but clang expects macosx12.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant