How to get the options with which clang was compiled - clang

It is possible to get gcc configure options with gcc -v (an example is here). Is there a similar way to retrieve the compilation options of clang?
My real task is the following one: I have an environment with a compiler (clang) which I want to improve. Now I have some patch for clang that I applied and I want to rebuild the patched sources, but I also want to be sure that nothing changes from the vanilla build apart from my patch; in particular, that all the build flags I use are the same.

No, probably not. But it's possible to get the CXXFLAGS/LDFLAGS clang was compiled with via llvm-config.
$ llvm-config --cxxflags
-I/opt/compiler/llvm-trunk/include -march=native -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -std=c++11 -ffunction-sections -fdata-sections -O3 -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
$ llvm-config --ldflags
-L/opt/compiler/llvm-trunk/lib
$ llvm-config --system-libs
-lrt -ldl -lcurses -latomic -lpthread -lz -lm
If you are on a Linux distribution, then simply check the PKGBUILD (or similar) to find the exact flags.

Related

Unable to install johnson with gem

I am trying to install johnson, in order to install harmony with Centos 8.
gem install johnson
I keep getting the error that there is no such file as node.h. But I have clearly installed nodejs, and nodejs-devel (I used the latest packages from stream: nodejs:18)
I am using Discourse community software, so require a specific version or ruby
current directory: /usr/local/share/gems/gems/johnson-1.2.0/ext/spidermonkey
make "DESTDIR="
gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/usr/local/share/gems/gems/johnson-1.2.0/vendor/spidermonkey/Linux_All_DBG.OBJ -I/usr/local/share/gems/gems/johnson-1.2.0/vendor/spidermonkey -fPIC -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC -g -Wall -Wextra -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline -DXP_UNIX -m64 -o context.o -c context.c
In file included from context.h:4,
from context.c:1:
spidermonkey.h:21: warning: "MAYBE_UNUSED" redefined
# define MAYBE_UNUSED(name) name __attribute__((unused))
In file included from /usr/include/ruby/config.h:18,
from /usr/include/ruby/ruby.h:24,
from /usr/include/ruby.h:33,
from spidermonkey.h:7,
from context.h:4,
from context.c:1:
/usr/include/ruby/config-x86_64.h:152: note: this is the location of the previous definition
#define MAYBE_UNUSED(x) __attribute__ ((__unused__)) x
gcc -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -I/usr/local/share/gems/gems/johnson-1.2.0/vendor/spidermonkey/Linux_All_DBG.OBJ -I/usr/local/share/gems/gems/johnson-1.2.0/vendor/spidermonkey -fPIC -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC -g -Wall -Wextra -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline -DXP_UNIX -m64 -o conversions.o -c conversions.c
In file included from conversions.h:4,
from conversions.c:1:
spidermonkey.h:21: warning: "MAYBE_UNUSED" redefined
# define MAYBE_UNUSED(name) name __attribute__((unused))
In file included from /usr/include/ruby/config.h:18,
from /usr/include/ruby/ruby.h:24,
from /usr/include/ruby.h:33,
from spidermonkey.h:7,
from conversions.h:4,
from conversions.c:1:
/usr/include/ruby/config-x86_64.h:152: note: this is the location of the previous definition
#define MAYBE_UNUSED(x) __attribute__ ((__unused__)) x
In file included from conversions.c:2:
js_land_proxy.h:11:10: fatal error: node.h: No such file or directory
#include "node.h"
^~~~~~~~
compilation terminated.
make: *** [Makefile:245: conversions.o] Error 1
make failed, exit code 2
Gem files will remain installed in /usr/local/share/gems/gems/johnson-1.2.0 for inspection.
Results logged to /usr/local/lib64/gems/ruby/johnson-1.2.0/gem_make.out

How do I clean a dart build? And modify the g++ flags?

I'm cross-building dart for armel (a client hired me to solve problems there)
I'm building on ubuntu 14.04 (the armel gcc/g++ is 4.7.3).
I want to take out -Werror since I'm seeing:
/usr/bin/arm-linux-gnueabi-g++ '-DDART_NO_SNAPSHOT' '-DDART_PRECOMPILER' '-DTARGET_ARCH_ARM' '-DNDEBUG' '-D_FORTIFY_SOURCE=2' -Iruntime -Werror -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wvla -Woverloaded-virtual -g3 -ggdb3 -fno-rtti -fno-exceptions -fstack-protector -Wa,--noexecstack -marm -mfpu=vfp -Wno-psabi -fno-strict-overflow -O3 -ffunction-sections -fno-omit-frame-pointer -MMD -MF out/ReleaseXARM/.deps/out/ReleaseXARM/obj.target/libdart_vm_nosnapshot/runtime/vm/compiler.o.d.raw -c -o out/ReleaseXARM/obj.target/libdart_vm_nosnapshot/runtime/vm/compiler.o runtime/vm/compiler.cc
In file included from runtime/vm/isolate.h:18:0,
from runtime/vm/growable_array.h:15,
from runtime/vm/compiler.h:9,
from runtime/vm/compiler.cc:5:
runtime/vm/thread.h: In static member function 'static dart::RawError* dart::Compiler::CompileClass(const dart::Class&)':
runtime/vm/thread.h:167:17: error: variable 'thread' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered]
cc1plus: all warnings being treated as errors
make: *** [out/ReleaseXARM/obj.target/libdart_vm_nosnapshot/runtime/vm/compiler.o] Error 1
BUILD FAILED
I'm working with this dart git tree:
commit 1d028eed8dfa00ac9d4ff685e61b01e6909dbeb4
Author: Paul Berry <paulberry#google.com>
Date: Wed Nov 30 12:28:51 2016 -0800
This is an actual bug in the code. One way to fix it would be to mark the thread variable volatile.

Compiling libidin.a to iOS

I want to compile the libidin.a framework to iOS but I ran into a terminal problem during so.
This is the guide i'm using to do that:
https://github.com/robbiehanson/XMPPFramework/wiki/CompilingLibidn
The guide says I should cd to the folder where the libidin.a is at and write the following line:
./configure --prefix=/usr/local/iphone --host=arm-apple-darwin --disable-shared CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.0.1 CFLAGS="-arch armv6 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=2.0 -gdwarf-2 -mthumb -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk" CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar
But I get the follwing answer:
-bash: ./configure: No such file or directory
Since I have no clue about what i'm doing in terminal, I really need your help.
Thanks
Ok,
I found out that I added the precompiled libidin.a file only one of my targets and this is why it failed.

Erros while installing 'therubyracer-heroku' gem

I am trying to do a gem install therubyracer-heroku -v '0.8.1.pre3', but I am getting errors while building, it is a big log but here is the last failing lines (pasted full log in the end):
g++ -o obj/release/bootstrapper.o -c -Wall -Werror -W -Wno-unused-parameter -Wnon-virtual-dtor -pedantic -m32 -O3 -fomit-frame-pointer -fdata-sections -ffunction-sections -ansi -fno-rtti -fno-exceptions -fvisibility=hidden -Wall -Werror -W -Wno-unused-parameter -Wnon-virtual-dtor -pedantic -m32 -O3 -fomit-frame-pointer -fdata-sections -ffunction-sections -ansi -DV8_TARGET_ARCH_IA32 -DENABLE_VMSTATE_TRACKING -DENABLE_LOGGING_AND_PROFILING -DENABLE_DEBUGGER_SUPPORT -Isrc src/bootstrapper.cc
src/bootstrapper.cc: In static member function 'static bool v8::internal::Genesis::CompileScriptCached(v8::internal::Vector<const char>, v8::internal::Handle<v8::internal::String>, v8::internal::SourceCodeCache*, v8::Extension*, v8::internal::Handle<v8::internal::Context>, bool)':
src/bootstrapper.cc:1002:18: error: variable 'result' set but not used [-Werror=unused-but-set-variable]
src/bootstrapper.cc: In member function 'bool v8::internal::Genesis::InstallNatives()':
src/bootstrapper.cc:1227:24: error: variable 'name' set but not used [-Werror=unused-but-set-variable]
cc1plus: all warnings being treated as errors
scons: *** [obj/release/bootstrapper.o] Error 1
scons: building terminated because of errors.
make: *** [build/v8/libv8.a] Error 2
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
I have googled about his for many hours and looked into a lot of SO similar questions, but nothing helped, also I don't know what is mkmf log mean and where to find it.
Additional information:
OS: Ubuntu, 12.04
I already have nodeJs installed, version is v0.8.14 (Just giving this info, since it may be linked with this)
Ruby version: 1.9.3
RVM is used

Error Compiling libc++ using Clang 3.0 on Ubuntu

When I try to compile libc++ (libcxx) on my Ubuntu 12.04 with LLVM 3.0 and Clang 3.0 i get the error
+ clang++ -c -g -Os -fPIC -std=c++0x -fstrict-aliasing -Wall -Wextra -Wshadow -Wconversion -Wnewline-eof -Wpadded -Wmissing-prototypes -Wstrict-aliasing=2 -Wstrict-overflow=4 -nostdinc++ -I../include ../src/stdexcept.cpp
../src/stdexcept.cpp:18:10: fatal error: 'cxxabi.h' file not found
#include <cxxabi.h>
^
1 error generated.
Where should I put cxxabi.h? It's currently in the following places
/usr/include/c++/4.4/cxxabi.h
/usr/include/c++/4.6/cxxabi.h
/usr/include/c++/4.7/cxxabi.h
My best guess is that any of these cxxabi.h will work. The only thing std except.cpp is looking for is if it is being used with libc++abi, which will be false for all 3 of your cxxabi.h.

Resources