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

clang driver: fix lost argv[0] #8883

Merged
merged 1 commit into from
May 24, 2021
Merged

clang driver: fix lost argv[0] #8883

merged 1 commit into from
May 24, 2021

Conversation

mikdusan
Copy link
Member

@mikdusan mikdusan commented May 24, 2021

  • stage1: fix lost argv[0] #3292 was unintentionally reverted by 56f433b
  • issue manifests on openbsd
  • issue does NOT manifest on freebsd because llvm 10 has added freebsd-specific code for getMainExecutable
  • most other bsd will manifest if /proc is not mounted
  • see llvm source

reduction: look for the 2 command lines using /usr/bin/clang

$ zig clang -### -c foo.S
clang version 12.0.0 (https://github.com/llvm/llvm-project.git fa0971b87fb2c9d14d1bba2551e61f02f18f329b)
Target: amd64-unknown-openbsd6.9
Thread model: posix
InstalledDir: /usr/bin
 "/usr/bin/clang" "-cc1" "-triple" "amd64-unknown-openbsd6.9" "-E" "-disable-free" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "foo.S" "-mrelocation-model" "pic" "-pic-level" "1" "-pic-is-pie" "-mframe-pointer=all" "-fno-rounding-math" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-fno-split-dwarf-inlining" "-debugger-tuning=gdb" "-resource-dir" "/usr/lib/clang/12.0.0" "-internal-isystem" "/usr/lib/clang/12.0.0/include" "-internal-externc-isystem" "/usr/include" "-fdebug-compilation-dir" "/home/mike/project/zig/work/main" "-ferror-limit" "19" "-stack-protector" "2" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-faddrsig" "-o" "/tmp/foo-57b2a5.s" "-x" "assembler-with-cpp" "foo.S"
 "/usr/bin/clang" "-cc1as" "-triple" "amd64-unknown-openbsd6.9" "-filetype" "obj" "-main-file-name" "foo.S" "-target-cpu" "x86-64" "-fdebug-compilation-dir" "/home/mike/project/zig/work/main" "-dwarf-debug-producer" "clang version 12.0.0 (https://github.com/llvm/llvm-project.git fa0971b87fb2c9d14d1bba2551e61f02f18f329b)" "-dwarf-version=2" "-mrelocation-model" "pic" "--mrelax-relocations" "-o" "foo.o" "/tmp/foo-57b2a5.s"
  1. a new argv is created from argv_ using a beginning offset is 1
  2. later the fallback path is INCORRECTLY set to argv[0] which happens to be clang or cc depending on the driver command; fallback should be argv_[0]
  3. llvm then searches path for those commands and execs the incorrect compiler

Verified

This commit was signed with the committer’s verified signature.
mikdusan Michael Dusan
@andrewrk andrewrk merged commit 1dc7764 into ziglang:master May 24, 2021
@andrewrk
Copy link
Member

Thanks- those comments will be helpful when inspecting the diff, and I also added a reminder to https://github.com/ziglang/zig/wiki/LLVM-Upgrade-Process.

@mikdusan mikdusan deleted the openbsd branch May 24, 2021 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants