[OE-core] [meta-clang] oe-core and meta-clang llvm coexsting?
Martin Kelly
mkelly at xevo.com
Thu Mar 30 23:58:01 UTC 2017
On 03/30/2017 12:31 PM, Khem Raj wrote:
>
>
> On 3/30/17 12:20 PM, Martin Kelly wrote:
>> Hi,
>>
>> I'm trying to integrate the meta-clang version of LLVM 4.0 (used for
>> recipes that need a newer LLVM version) alongside the oe-core version of
>> LLVM 3.3 (used for mesa). I'd like some recipes to use LLVM 4.0 and some
>> to use LLVM 3.3 and for them not to collide with each other.
>>
>> Right now, once the meta-clang layer is enabled, the recipes collide
>> because they both provide llvm-common.bb. I tried explicitly versioning
>> llvm-common, which makes them no longer collide. However, mesa then
>> fails to build because the meta-clang version of LLVM installs
>> llvm-config into the native common sysroot in
>
> merging all llvm-common into a single recipe might be good
I agree that this would be a good idea. However, at this point the two
llvm-configs have diverged and return very different sets of flags, so
they are basically incompatible. Specifically, the oe-core version of
LLVM returns a set of flags that are not the same as the native
CPPFLAGS, CFLAGS, etc, while the meta-clang version of llvm-config
returns a set of flags that are the exact same as CPPFLAGS, CFLAGS, etc.
See below for the full flag settings in both versions.
Clearly, using CPPFLAGS, CFLAGS, etc. directly breaks cross-compilation.
For this reason, I added wrapper logic to return TARGET_CPPFLAGS,
TARGET_CFLAGS, etc. in the meta-clang script, which allowed it to
properly cross-compile. However, this wrapper logic, and the set of
flags that the meta-clang llvm-config returns, is incompatible with what
mesa expects when it calls llvm-config.
AFAICT, this difference in flags boils down to differences between the
LLVM autotools-based build and the CMake build. For example, in LLVM
3.3, the autotools build set LLVM_LDFLAGS like this:
./tools/llvm-config/Makefile:50: $(Verb) $(ECHO)
's/@LLVM_LDFLAGS@/$(subst /,\/,$(SUB_LDFLAGS))/' \
and SUB_LDFLAGS is empty:
./tools/llvm-config/Makefile:36:SUB_LDFLAGS :=
As a result, in the autotools-based LLVM 3.3, we get:
#define LLVM_LDFLAGS ""
... while the CMake LLVM 4.0 returns the host LDFLAGS, thus
necessitating the wrapper logic for proper cross-compilation.
In short, (this is just a guess), it appears that the CMake LLVM build
doesn't do cross-compilation properly, while the autotools-based build does.
I think that's the problem. Fixing it is harder :). We can always
version both libraries rather than merging llvm-config, but that's ugly
and not a great long-term strategy.
Can you think of a cleaner way to do this?
Flags:
-----------------------------------------------------------------------
LLVM 3.3 oe-core BuildVariables.inc, after configure step:
#define LLVM_CPPFLAGS " -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
#define LLVM_CFLAGS " -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -O3 -fomit-frame-pointer -fPIC"
#define LLVM_LDFLAGS ""
#define LLVM_CXXFLAGS " -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -O3 -fomit-frame-pointer
-fvisibility-inlines-hidden -fno-exceptions -fPIC -Woverloaded-virtual
-Wcast-qual"
-----------------------------------------------------------------------
LLVM 4.0 meta-clang BuildVariables.inc, after configure step:
-----------------------------------------------------------------------
#define LLVM_CPPFLAGS " -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
#define LLVM_CFLAGS "
-isystem[snip]/build/qemux86-64/tmp/sysroots/x86_64-linux/usr/include
-O2 -pipe -fPIC -Wall -W -Wno-unused-parameter -Wwrite-strings
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-comment
-Werror=date-time -ffunction-sections -fdata-sections -DNDEBUG
-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS"
#define LLVM_LDFLAGS "
-isystem[snip]/build/qemux86-64/tmp/sysroots/x86_64-linux/usr/include
-O2 -pipe -D_GLIBCXX_USE_CXX11_ABI=0
-L[snip]/build/qemux86-64/tmp/sysroots/x86_64-linux/usr/lib
-L[snip]/build/qemux86-64/tmp/sysroots/x86_64-linux/lib
-Wl,-rpath-link,[snip]/build/qemux86-64/tmp/sysroots/x86_64-linux/usr/lib
-Wl,-rpath-link,[snip]/build/qemux86-64/tmp/sysroots/x86_64-linux/lib
-Wl,-rpath,[snip]/build/qemux86-64/tmp/sysroots/x86_64-linux/usr/lib
-Wl,-rpath,[snip]/build/qemux86-64/tmp/sysroots/x86_64-linux/lib -Wl,-O1"
#define LLVM_CXXFLAGS "
-isystem[snip]/build/qemux86-64/tmp/sysroots/x86_64-linux/usr/include
-O2 -pipe -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -fvisibility-inlines-hidden
-Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual
-Wno-missing-field-initializers -pedantic -Wno-long-long
-Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment
-Werror=date-time -std=c++11 -ffunction-sections -fdata-sections
-DNDEBUG -fno-exceptions -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
-----------------------------------------------------------------------
More information about the Openembedded-core
mailing list