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

fix zig cc to convert zig-triple → llvm-triple #8232

Closed
wants to merge 1 commit into from

Conversation

mikdusan
Copy link
Member

@mikdusan mikdusan commented Mar 13, 2021

  • issue manifested when piping to zig cc -E -

  • zig passed zig-triples when punting to clang, preprocessing and with piped input

  • look for native in target strings below to see indicators of the bug

  • BEFORE

! zig cc -E -v -target native-linux - < /dev/null
  
- Target: native-unknown-linux
  Thread model: posix
  InstalledDir: /usr/bin
   (in-process)
   "/home/mike/project/zig/work/main/_build/zig"
      -cc1
-     -triple native-unknown-linux
      -E
      -disable-free
      -disable-llvm-verifier
      -discard-value-names
      -main-file-name
      -
      -mrelocation-model static
      -mframe-pointer=all
      -fmath-errno
      -fno-rounding-math
      -fno-verbose-asm
      -no-integrated-as
      -mconstructor-aliases
      -fno-split-dwarf-inlining
      -debugger-tuning=gdb
      -v
      -resource-dir /home/mike/project/zig/work/main/lib/clang/11.0.1
      -internal-isystem /usr/local/include
      -internal-isystem /home/mike/project/zig/work/main/lib/clang/11.0.1/include
      -internal-externc-isystem /include
      -internal-externc-isystem /usr/include
      -fno-dwarf-directory-asm
      -fdebug-compilation-dir /home/mike/project/zig/work/main
      -ferror-limit 19
      -fgnuc-version=4.2.1
      -fcolor-diagnostics
      -o
      -
      -x c
      -
- error: unknown target triple 'native-unknown-linux', please use -triple or -arch
  • AFTER
! zig cc -E -v -target native-linux - < /dev/null
  
+ Target: x86_64-unknown-linux-musl
  Thread model: posix
  InstalledDir: /usr/bin
   (in-process)
   "/home/mike/project/zig/work/zigcc/_build/zig"
      -cc1
+     -triple x86_64-unknown-linux-musl
      -E
      -disable-free
      -disable-llvm-verifier
      -discard-value-names
      -main-file-name
      -
      -mrelocation-model pic
      -pic-level 2
      -pic-is-pie
      -mframe-pointer=all
      -fmath-errno
      -fno-rounding-math
      -mconstructor-aliases
      -munwind-tables
      -target-cpu x86-64
      -fno-split-dwarf-inlining
      -debugger-tuning=gdb
      -v
      -resource-dir /home/mike/project/zig/work/zigcc/lib/clang/11.0.1
      -internal-isystem /usr/local/include
      -internal-externc-isystem /include
      -internal-externc-isystem /usr/include
      -internal-isystem /home/mike/project/zig/work/zigcc/lib/clang/11.0.1/include
      -fdebug-compilation-dir /home/mike/project/zig/work/zigcc
      -ferror-limit 19
      -fgnuc-version=4.2.1
      -fcolor-diagnostics
      -faddrsig
      -o
      -
      -x c
      -
+ # 1 "<stdin>"
+ # 1 "<built-in>" 1
+ # 1 "<built-in>" 3
+ # 345 "<built-in>" 3
+ # 1 "<command line>" 1
+ # 1 "<built-in>" 2
+ # 1 "<stdin>" 2

- issue manifested when piping to `zig cc -E -`
@mikdusan mikdusan added frontend Tokenization, parsing, AstGen, Sema, and Liveness. zig cc Zig as a drop-in C compiler feature labels Mar 13, 2021
@LemonBoy
Copy link
Contributor

#7360 is somewhat related and relatively straightforward to fix once we decide how to handle that.

@mikdusan mikdusan marked this pull request as draft March 13, 2021 21:03
@@ -1417,8 +1421,22 @@ fn buildOutputType(
output_mode = .Obj;
// An error message is generated when there is more than 1 C source file.
if (c_source_files.items.len != 1) {
const punt_args = blk: {
Copy link
Member Author

@mikdusan mikdusan Mar 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after talking with andrew, going to rework PR with new approach:

  • consider piped-input preprocessor the same as having 1 source file and avoid punt_to_clang() altogether
  • adjust rest of fn body to handle accordingly

@andrewrk
Copy link
Member

30+ days old draft; closing

@andrewrk andrewrk closed this May 20, 2021
@mikdusan mikdusan deleted the zigcc branch September 19, 2023 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend Tokenization, parsing, AstGen, Sema, and Liveness. zig cc Zig as a drop-in C compiler feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants