Skip to content

building of clang for SDK fails due to -fPIC is not supported #975

@ceggers-arri

Description

@ceggers-arri

OE Version: Yocto Scarthgap

I've tried to build clang for SDK by adding the meta-clang
layer to my build and setting CLANGSDK = "1" in my local.conf.
But when running bitbake myrootfs -c populate_sdk, linking of
libLLVM.so.18.1 fails with the following error messages:

/build/devel-scarthgap/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-clang/18.1.5/recipe-sysroot-native/usr/bin/x86_64-pokysdk-linux/x86_64-pokysdk-linux-ld: lib/libLLVMSupport.a(CrashRecoveryContext.cpp.o): relocation R_X86_64_TPOFF32 against `_ZN12_GLOBAL__N_121IsRecoveringFromCrashE' can not be used when making a shared object; recompile with -fPIC
/build/devel-scarthgap/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-clang/18.1.5/recipe-sysroot-native/usr/bin/x86_64-pokysdk-linux/x86_64-pokysdk-linux-ld: failed to set dynamic section sizes: bad value
x86_64-pokysdk-linux-clang++: error: linker command failed with exit code 1 (use -v to see invocation)

I can see that -fPIC as actually not set during compilation of CrashRecoveryContext.cpp. In the log.do_compile this switch is only set for 36 out of 6320 source files. When I compare this with the native clang build, I see that -fPIC is set for almost all files.

The log.do_configure for native includes the following:

-- Performing Test C_SUPPORTS_FPIC
-- Performing Test C_SUPPORTS_FPIC - Success
-- Performing Test CXX_SUPPORTS_FPIC
-- Performing Test CXX_SUPPORTS_FPIC - Success
-- Building with -fPIC

But for nativesdk this is different:

-- Performing Test C_SUPPORTS_FPIC
-- Performing Test C_SUPPORTS_FPIC - Failed
-- Performing Test CXX_SUPPORTS_FPIC
-- Performing Test CXX_SUPPORTS_FPIC - Failed
CMake Warning at cmake/modules/HandleLLVMOptions.cmake:320 (message):
  -fPIC is not supported.
Call Stack (most recent call first):
  cmake/modules/HandleLLVMOptions.cmake:380 (add_flag_or_print_warning)
  CMakeLists.txt:936 (include)wq

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions