I am trying to find clang equivalent to gcc's gcc -v -march=native -E - </dev/null command.
What this command does is that, I run it on my target system where I want my final program to run. Fetch the flags that gcc would use to optimize it according to the target system. And then build it on my system with those flags after that.
What the clang equivalent (i.e. clang -v -march=native -E - </dev/null) does is almost the same but the case is that the final output cannot be directly copied to use during compilation. Some flags printed by this command donot work with clang command line compilation. I would be grateful if someone who faced a similar situation could help on this.
A sample output of clang flags is :
"/usr/bin/clang-13" -cc1 -triple x86_64-pc-linux-gnu -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 goldmont -target-feature +sse2 -target-feature -tsxldtrk -target-feature +cx16 -target-feature +sahf -target-feature -tbm -target-feature -avx512ifma -target-feature +sha -target-feature +gfni -target-feature -fma4 -target-feature -vpclmulqdq -target-feature +prfchw -target-feature +bmi2 -target-feature -cldemote -target-feature +fsgsbase -target-feature +ptwrite -target-feature -amx-tile -target-feature -uintr -target-feature +popcnt -target-feature +widekl -target-feature +aes -target-feature -avx512bitalg -target-feature +movdiri -target-feature -xsaves -target-feature -avx512er -target-feature -avxvnni -target-feature -avx512vnni -target-feature -amx-bf16 -target-feature -avx512vpopcntdq -target-feature +pconfig -target-feature +clwb -target-feature -avx512f -target-feature -xsavec -target-feature -clzero -target-feature +pku -target-feature +mmx -target-feature -lwp -target-feature +rdpid -target-feature -xop -target-feature +rdseed -target-feature +waitpkg -target-feature +kl -target-feature +movdir64b -target-feature -sse4a -target-feature -avx512bw -target-feature +clflushopt -target-feature -xsave -target-feature -avx512vbmi2 -target-feature +64bit -target-feature -avx512vl -target-feature +serialize -target-feature +hreset -target-feature +invpcid -target-feature -avx512cd -target-feature -avx -target-feature -vaes -target-feature -avx512bf16 -target-feature +cx8 -target-feature -fma -target-feature -rtm -target-feature +bmi -target-feature -enqcmd -target-feature +rdrnd -target-feature -mwaitx -target-feature +sse4.1 -target-feature +sse4.2 -target-feature -avx2 -target-feature +fxsr -target-feature -wbnoinvd -target-feature +sse -target-feature +lzcnt -target-feature +pclmul -target-feature -prefetchwt1 -target-feature -f16c -target-feature +ssse3 -target-feature -sgx -target-feature +shstk -target-feature +cmov -target-feature -avx512vbmi -target-feature -amx-int8 -target-feature +movbe -target-feature -avx512vp2intersect -target-feature -xsaveopt -target-feature -avx512dq -target-feature +adx -target-feature -avx512pf -target-feature +sse3 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/home/trading/users/hardik/clang_examples -resource-dir /usr/lib/clang/13.0.0 -internal-isystem /usr/lib/clang/13.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../x86_64-pc-linux-gnu/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/home/trading/users/hardik/clang_examples -ferror-limit 19 -stack-protector 2 -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o - -x c -
The following errors arise when I try to copy these:
cc: error: unrecognized command-line option ‘-main-file-name’; did you mean ‘--print-file-name’?
cc: error: unrecognized command-line option ‘-mrelocation-model’
cc: error: unrecognized command-line option ‘-pic-level’
cc: error: unrecognized command-line option ‘-pic-is-pie’
cc: error: unrecognized command-line option ‘-mframe-pointer=all’
cc: error: unrecognized command-line option ‘-mconstructor-aliases’
cc: error: unrecognized command-line option ‘-munwind-tables’; did you mean ‘-funwind-tables’?
cc: error: unrecognized command-line option ‘-target-cpu’
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-tsxldtrk’; did you mean ‘-mtsxldtrk’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-tbm’; did you mean ‘-mtbm’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-avx512ifma’; did you mean ‘-mavx512ifma’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-fma4’; did you mean ‘-mfma4’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-vpclmulqdq’; did you mean ‘-mvpclmulqdq’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-cldemote’; did you mean ‘-mcldemote’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-amx-tile’; did you mean ‘-mamx-tile’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-avx512bitalg’; did you mean ‘-mavx512bitalg’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-avx512er’; did you mean ‘-mavx512er’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-avxvnni’; did you mean ‘-mavxvnni’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-avx512vnni’; did you mean ‘-mavx512vnni’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-amx-bf16’; did you mean ‘-mamx-bf16’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-avx512vpopcntdq’; did you mean ‘-mavx512vpopcntdq’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-avx512f’; did you mean ‘-mavx512f’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-clzero’; did you mean ‘-mclzero’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-sse4a’; did you mean ‘-msse4a’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-avx512bw’; did you mean ‘-mavx512bw’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-avx512vbmi2’; did you mean ‘-mavx512vbmi2’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-avx512vl’; did you mean ‘-mavx512vl’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-avx512cd’; did you mean ‘-mavx512cd’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-avx’; did you mean ‘-mavx’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-vaes’; did you mean ‘-maes’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-avx512bf16’; did you mean ‘-mavx512bf16’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-fma’; did you mean ‘-mfma’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-rtm’; did you mean ‘-mrtm’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-mwaitx’; did you mean ‘-mmwaitx’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-avx2’; did you mean ‘-mavx2’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-wbnoinvd’; did you mean ‘-mwbnoinvd’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-prefetchwt1’; did you mean ‘-mprefetchwt1’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-f16c’; did you mean ‘-mf16c’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-sgx’; did you mean ‘-msgx’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-avx512vbmi’; did you mean ‘-mavx512vbmi’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-amx-int8’; did you mean ‘-mamx-int8’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-avx512vp2intersect’; did you mean ‘-mavx512vp2intersect’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-avx512dq’; did you mean ‘-mavx512dq’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-avx512pf’; did you mean ‘-mavx512pf’?
cc: error: unrecognized command-line option ‘-target-feature’; did you mean ‘-Wtarget-lifetime’?
cc: error: unrecognized command-line option ‘-fcoverage-compilation-dir=/home/trading’
cc: error: unrecognized command-line option ‘-resource-dir’
cc: error: unrecognized command-line option ‘-internal-isystem’
cc: error: unrecognized command-line option ‘-internal-isystem’
cc: error: unrecognized command-line option ‘-internal-isystem’
cc: error: unrecognized command-line option ‘-internal-externc-isystem’
cc: error: unrecognized command-line option ‘-internal-externc-isystem’
cc: error: unrecognized command-line option ‘-fdebug-compilation-dir=/home/trading’
cc: error: unrecognized command-line option ‘-ferror-limit’
cc: error: unrecognized command-line option ‘-stack-protector’; did you mean ‘-Wstack-protector’?
cc: error: unrecognized command-line option ‘-fgnuc-version=4.2.1’
cc: error: unrecognized command-line option ‘-faddrsig’