I want to know why
clang --help
does not show any explanation for options like -O1, -O2 or -O3 ? Any idea?
My OS is Mac OS 10.9.5.
Related
I'm trying to compile a wasm binary with multivalue and O3, however, I keep getting [wasm-validator error in module] unexpected false: Imported multivalue function requires multivalue [--enable-multivalue].
The current flags that I'm using are --target=wasm32-unknown-unknown-wasm -O3 -nostdlib -funroll-loops -Wall -Wno-comment -mllvm -polly -mmultivalue -Xclang -target-abi -Xclang experimental-mv -ffunction-sections -fdata-sections -flto -s -Wl,--export-dynamic,--allow-undefined,--gc-sections.
No, sadly there is no way (today) to modify the wasm-opt command line that clang uses.
This seems like a bug in llvm and really the target-features section of binary should contains multivalue, which should then enable it automatically in wasm-opt. Could you open an llvm bug about this?
For now your best bet might be to run clang without wasm-opt in your PATH.
I am building with Clang 9.0.0 and linking with the ld.lld linker
clang++.exe -Wall -fexceptions -m64 -O3 -Xclang -flto-visibility-public-std -std=c++2a -flto=thin -c
I:\Cpp\hello_boost\hello_codeblocks_world\hello_codeblocks_world.cpp -o obj\release\hello_codeblocks_world.o
clang++.exe -o bin\release\hello_codeblocks_world.exe obj\release\hello_codeblocks_world.o -m64 -fuse-ld=lld --strip-all
but, unlike when using the usual GCC linker LD, this option (--strip-all or -s) is not recognized
clang++: error: unsupported option '--strip-all' (or similarly with -s)
Can anyone suggest what I should be doing to strip symbols?
(My release-mode hello_world.exe size is 15 kb for GC but 230 kB for Clang :-( and this is likely to have some adverse effects for no benefit).
Is this not an option for ld.lld ?
Thanks
You might want to use:
-Xlinker --strip-all
You can use this to supply system-specific linker options that GCC does not recognize (gcc manual)
https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
I have compiled the C code to LLVM IR code with -O0 optimization.
How can I convert this -O0 LLVM IR code to the -O3 LLVM IR code "without the C code"?
I have tried below:
clang -O3 -S -emit-llvm O0.ll -o O3.ll
and
opt -O3 -S O0.ll -o O3.ll
but the output is still -O0 level.
Thank you.
I'm not sure when the change happened (I think it's LLVM 3.9.0 and on), but when you compile to bitcode functions get annotated with the optnone attribute and further optimizations are not performed.
Have a look for a relevant SO discussion here.
What is suggested is to do this:
clang -emit-llvm -O1 -mllvm -disable-llvm-optzns -disable-llvm-passes foo.c -o foo.bc
For LLVM 3.8.0 and earlier (I think) what you have already been doing is enough.
So, once you obtain that bitcode (without the optnone) argument, you can use opt as you've already been doing.
recently I updated my armadillo to version 5.200.1, but when i tried to compile my code using
g++ -std=c++11 -m64 -O3 -Wall -I. -I/opt/OpenBLAS/include -fopenmp -o code.cpp.o -c code.cpp
g++ -std=c++11 -m64 -O3 -Wall -I. -I/opt/OpenBLAS/include -fopenmp -o main.cpp.o -c main.cpp
g++ -std=c++11 -m64 -O3 -o code.cpp.o main.cpp.o -lgomp -L/opt/OpenBLAS/lib -lopenblas -larmadillo
I got error message in the final linking step
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../lib/libarmadillo.so:
undefined reference to `pthread_atfork'
collect2: error: ld returned 1 exit status
make: *** [a.out] Error 1
This error appears in my machine with Ubuntu 14.04LTS + gcc 4.9.2.
The Armadillo itself is linked with OpenBLAS 0.2.14 (I followed the procedure provided by Armadillo in installation)
such error doesn't occur in my macosx laptop (the same library). It means something problems with my ubuntu machine. I tried to re-install the Armadillo 4.650.2 (this version worked before), but the same error kept appearing (now older doesn't work like before). The only thing that i did before updating those libraries were "apt-self update" and "apt-self upgrade" of my ubuntu machine
is there any suggestion to fix this problem?
I also use armadillo on Ubuntu Linux
I had the same problem first when I started to program with armadillo. For g++ I only had to add -larmadillo as command line option. such as this
g++ -O2 -o armadillo_example armadillo_example.cpp -larmadillo
Hope someone can shed a light on this issue for me. I am building ruby 32bit in RHEL 6 x86_64 using rvm. Followed this guide(ignored Mac related stuffs), I ran
rvm_archflags="-arch i386" CFLAGS="-arch i386" LDFLAGS="-arch i386"
rvm install 1.9.2
I get an error like this:
Error running './configure --disable-install-doc --prefix=/home/deploy/.rvm/rubies/ruby-1.8.7-p371 --enable-shared'
Trying original method: rvm install 1.8.7 --32 and got this:
'env MACOSX_DEPLOYMENT_TARGET= CFLAGS=-O3 -arch i386 -g -Os -pipe
-no-cpp-precomp CCFLAGS=-arch i386 -g -Os -pipe CXXFLAGS=-arch i386 -g -Os -pipe LDFLAGS=-arch i386 -bind_at_load LDSHARED=cc -arch i386 -dynamiclib -undefined suppress -flat_namespace ./configure --disable-install-doc --prefix=/home/deploy/.rvm/rubies/ruby-1.8.7-p371 --enable-shared'
Looking at the config.log, it says C compiler cannot create executables. From the look of the errors, I guess it mismatched the target machine(Mac instead of RHEL). I don't quite understand why because the gcc is definitely built for x86_64 Red Hat linux. Can someone give me a hint on this issue?
Thanks alot
Compiling in 32bit requires using the -m32 option on linux. The -arch i386 option is Mac specific.
You will, of course require the full suite of 32bit development libraries.