Skip to content

when passing -### ("dry_run") avoid actually running compilation and linking child processes #7170

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

Open
andrewrk opened this issue Nov 19, 2020 · 3 comments · Fixed by #15738
Labels
bug Observed behavior contradicts documented or intended behavior enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig cc Zig as a drop-in C compiler feature
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented Nov 19, 2020

zig/src/main.zig

Lines 1072 to 1076 in 8eaaa90

.dry_run => {
verbose_link = true;
try clang_argv.append("-###");
// XXX: Don't execute anything!
},

Follow-up to #7166

@andrewrk andrewrk added enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig cc Zig as a drop-in C compiler feature labels Nov 19, 2020
@andrewrk andrewrk added this to the 0.8.0 milestone Nov 19, 2020
@FireFox317
Copy link
Contributor

Ah that is probably why the configure step in CMake is so slow.

@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Jun 4, 2021
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 Nov 24, 2021
@andrewrk andrewrk modified the milestones: 0.10.0, 0.11.0 Apr 16, 2022
@motiejus
Copy link
Contributor

This is a problem for Golang, as it runs -### to understand some things about the compiler:

Zig today:

$ zig cc -### -x c - 
-:1:1: error: unable to build C object: FileNotFound

clang-16 today:

$ clang-16 -### -x c - 
Ubuntu clang version 16.0.1 (++20230328073357+42d1b276f779-1~exp1~20230328073502.65)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
 "/usr/lib/llvm-16/bin/clang" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "-" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-mllvm" "-treat-scalable-fixed-error-as-warning" "-debugger-tuning=gdb" "-fcoverage-compilation-dir=/code/zig/build" "-resource-dir" "/usr/lib/llvm-16/lib/clang/16" "-internal-isystem" "/usr/lib/llvm-16/lib/clang/16/include" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include" "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-fdebug-compilation-dir=/code/zig/build" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "/tmp/--55cca3.o" "-x" "c" "-"
 "/usr/bin/ld" "-pie" "-z" "relro" "--hash-style=gnu" "--build-id" "--eh-frame-hdr" "-m" "elf_x86_64" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "a.out" "/lib/x86_64-linux-gnu/Scrt1.o" "/lib/x86_64-linux-gnu/crti.o" "/usr/bin/../lib/gcc/x86_64-linux-gnu/11/crtbeginS.o" "-L/usr/bin/../lib/gcc/x86_64-linux-gnu/11" "-L/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../lib64" "-L/lib/x86_64-linux-gnu" "-L/lib/../lib64" "-L/usr/lib/x86_64-linux-gnu" "-L/usr/lib/../lib64" "-L/usr/lib/llvm-16/bin/../lib" "-L/lib" "-L/usr/lib" "/tmp/--55cca3.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "/usr/bin/../lib/gcc/x86_64-linux-gnu/11/crtendS.o" "/lib/x86_64-linux-gnu/crtn.o"

zig with #14462 : better, but still not compatible:

$ echo  | stage4/bin/zig cc -### -x c - 
Ubuntu clang version 16.0.1 (++20230328073357+42d1b276f779-1~exp1~20230328073502.65)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /code/zig/build
 (in-process)
 "/code/zig/build/stage4/bin/zig" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "11b2af1f83bd4f4f-stdin.c" "-mrelocation-model" "pic" "-pic-level" "2" "-fhalf-no-semantic-interposition" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-mllvm" "-treat-scalable-fixed-error-as-warning" "-debug-info-kind=constructor" "-dwarf-version=4" "-debugger-tuning=gdb" "-fcoverage-compilation-dir=/code/zig/build" "-nostdsysteminc" "-nobuiltininc" "-resource-dir" "/code/zig/build/stage4/lib/clang/16" "-dependency-file" "/home/motiejus/.cache/zig/tmp/31c071f0ffbd175a-11b2af1f83bd4f4f-stdin.o.d" "-MT" "/home/motiejus/.cache/zig/tmp/31c071f0ffbd175a-11b2af1f83bd4f4f-stdin.o" "-sys-header-deps" "-MV" "-isystem" "/code/zig/lib/include" "-isystem" "/usr/include" "-isystem" "/usr/include/x86_64-linux-gnu" "-isystem" "/usr/local/include" "-isystem" "/usr/include/x86_64-linux-gnu" "-isystem" "/usr/include" "-D" "__GLIBC_MINOR__=35" "-D" "_DEBUG" "-O0" "-fdebug-compilation-dir=/code/zig/build" "-ferror-limit" "19" "-fsanitize=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound" "-fsanitize-trap=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound" "-fno-sanitize-memory-param-retval" "-fno-sanitize-address-use-odr-indicator" "-stack-protector" "2" "-stack-protector-buffer-size" "4" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-fno-spell-checking" "-target-cpu" "skylake" "-target-feature" "-16bit-mode" "-target-feature" "-32bit-mode" "-target-feature" "-3dnow" "-target-feature" "-3dnowa" "-target-feature" "+64bit" "-target-feature" "+adx" "-target-feature" "+aes" "-target-feature" "+allow-light-256-bit" "-target-feature" "-amx-bf16" "-target-feature" "-amx-fp16" "-target-feature" "-amx-int8" "-target-feature" "-amx-tile" "-target-feature" "+avx" "-target-feature" "+avx2" "-target-feature" "-avx512bf16" "-target-feature" "-avx512bitalg" "-target-feature" "-avx512bw" "-target-feature" "-avx512cd" "-target-feature" "-avx512dq" "-target-feature" "-avx512er" "-target-feature" "-avx512f" "-target-feature" "-avx512fp16" "-target-feature" "-avx512ifma" "-target-feature" "-avx512pf" "-target-feature" "-avx512vbmi" "-target-feature" "-avx512vbmi2" "-target-feature" "-avx512vl" "-target-feature" "-avx512vnni" "-target-feature" "-avx512vp2intersec
t" "-target-feature" "-avx512vpopcntdq" "-target-feature" "-avxifma" "-target-feature" "-avxneconvert" "-target-feature" "-avxvnni" "-target-feature" "-avxvnniint8" "-target-feature" "+bmi" "-target-feature" "+bmi2" "-target-feature" "-branchfusion" "-target-feature" "-cldemote" "-target-feature" "+clflushopt" "-targe
t-feature" "-clwb" "-target-feature" "-clzero" "-target-feature" "+cmov" "-target-feature" "-cmpccxadd" "-target-feature" "+crc32" "-target-feature" "+cx16" "-target-feature" "+cx8" "-target-feature" "-enqcmd" "-target-feature" "+ermsb" "-target-feature" "+f16c" "-target-feature" "-false-deps-getmant" "-target-feature" "-false-deps-lzcnt-tzcnt" "-target-feature" "-false-deps-mulc" "-target-feature" "-false-deps-mullq" "-target-feature" "-false-deps-perm" "-target-feature" "+false-deps-popcnt" "-target-feature" "-false-deps-range" "-target-feature" "-fast-11bytenop" "-target-feature" "+fast-15bytenop" "-target-feature" "-fast-7bytenop" "-target-feature" "-fast-bextr" "-target-feature" "+fast-gather" "-target-feature" "-fast-hops" "-target-feature" "-fast-lzcnt" "-target-feature" "-fast-movbe" "-target-feature" "+fast-scalar-fsqrt" "-target-feature" "-fast-scalar-shift-masks" "-target-feature" "+fast-shld-rotate" "-target-feature" "+fast-variable-crosslane-shuffle" "-target-feature" "+fast-variable-perlane-shuffle" "-target-feature" "+fast-vector-fsqrt" "-target-feature" "-fast-vector-shift-masks" "-target-feature" "+fma" "-target-feature" "-fma4" "-target-feature" "+fsgsbase" "-target-feature" "-fsrm" "-target-feature" "+fxsr" "-target-feature" "-gfni" "-target-feature" "-harden-sls-ijmp" "-target-feature" "-harden-sls-ret" "-target-feature" "-hreset" "-target-feature" "-idivl-to-divb" "-target-feature" "+idivq-to-divl" "-target-feature" "+invpcid" "-target-feature" "-kl" "-target-feature" "-lea-sp" "-target-feature" "-lea-uses-ag" "-target-feature" "-lvi-cfi" "-target-feature" "-lvi-load-hardening" "-target-feature" "-lwp" "-target-feature" "+lzcnt" "-target-feature" "+macrofusion" "-target-feature" "+mmx" "-target-feature" "+movbe" "-target-feature" "-movdir64b" "-target-feature" "-movdiri" "-target-feature" "-mwaitx" "-target-feature" "+nopl" "-target-feature" "-pad-short-functions" "-target-feature" "+pclmul" "-target-feature" "-pconfig" "-target-feature" "-pku" "-target-feature" "+popcnt" "-target-feature" "-prefer-128-bit" "-target-feature" "-prefer-256-bit" "-target-feature" "-prefer-mask-registers" "-target-feature" "-prefetchi" "-target-feature" "-prefetchwt1" "-target-feature" "+prfchw
" "-target-feature" "-ptwrite" "-target-feature" "-raoint" "-target-feature" "-rdpid" "-target-feature" "-rdpru" "-target-feature" "+rdrnd" "-target-feature" "+rdseed" "-target-feature" "-retpoline" "-target-feature" "-retpoline-external-thunk" "-target-feature" "-retpoline-indirect-branches" "-target-feature" "-retpoline-indirect-calls" "-target-feature" "+rtm" "-target-feature" "+sahf" "-target-feature" "-sbb-dep-breaking" "-target-feature" "-serialize" "-target-feature" "-seses" "-target-feature" "+sgx" "-target-feature" "-sha" "-target-feature" "-shstk" "-target-feature" "+slow-3ops-lea" "-target-feature" "-slow-incdec" "-target-feature" "-slow-lea" "-target-feature" "-slow-pmaddwd" "-target-feature" "-slow-pmulld" "-target-feature" "-slow-shld" "-target-feature" "-slow-two-mem-ops" "-target-feature" "-slow-unaligned-mem-16" "-target-feature" "-slow-unaligned-mem-32" "-target-feature" "-soft-float" "-target-feature" "+sse" "-target-feature" "+sse2" "-target-feature" "+sse3" "-target-feature" "+sse4.1" "-target-feature" "+sse4.2" "-target-feature" "-sse4a" "-target-feature" "-sse-unaligned-mem" "-target-feature" "+ssse3" "-target-feature" "-tagged-globals" "-target-feature" "-tbm" "-target-feature" "-tsxldtrk" "-target-feature" "-uintr" "-target-feature" "-use-glm-div-sqrt-costs" "-target-feature" "-use-slm-arith-costs" "-target-feature" "-vaes" "-target-feature" "-vpclmulqdq" "-target-feature" "+vzeroupper" "-target-feature" "-waitpkg" "-target-feature" "-wbnoinvd" "-target-feature" "-widekl" "-target-feature" "+x87" "-target-feature" "-xop" "-target-feature" "+xsave" "-target-feature" "+xsavec" "-target-feature" "+xsaveopt" "-target-feature" "+xsaves" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "/home/motiejus/.cache/zig/tmp/31c071f0ffbd175a-11b2af1f83bd4f4f-stdin.o" "-x" "c" "/home/motiejus/.cache/zig/tmp/11b2af1f83bd4f4f-stdin.c"
/home/motiejus/.cache/zig/tmp/11b2af1f83bd4f4f-stdin.c:1:1: error: unable to build C object: FileNotFound

@andrewrk andrewrk added the bug Observed behavior contradicts documented or intended behavior label May 16, 2023
andrewrk added a commit that referenced this issue May 17, 2023
@andrewrk
Copy link
Member Author

Still a problem when -c is not used. See discussion here: #15738 (comment)

@andrewrk andrewrk reopened this May 17, 2023
@andrewrk andrewrk modified the milestones: 0.11.0, 0.11.1 Jul 22, 2023
@andrewrk andrewrk modified the milestones: 0.11.1, 0.12.0, 0.13.0 Jan 29, 2024
@andrewrk andrewrk modified the milestones: 0.14.0, 0.16.0 Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig cc Zig as a drop-in C compiler feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants