Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting CLANG_DEFAULT_PIE_ON_LINUX when building clang #228

Open
swahtz opened this issue Oct 22, 2024 · 1 comment
Open

Setting CLANG_DEFAULT_PIE_ON_LINUX when building clang #228

swahtz opened this issue Oct 22, 2024 · 1 comment

Comments

@swahtz
Copy link

swahtz commented Oct 22, 2024

It seems that the behaviour for whether or not -fPIE is on by default in Linux changed in clang 14 to be controlled by a flag when building clang:

llvm/llvm-project@1042de9

We were having a bit of an issue switching to the 2024 OS CI images and building with clang++ on the OpenVDB project (when moving from 2022 clang11 to the 2024 image):

AcademySoftwareFoundation/openvdb#1926

Shall we set CLANG_DEFAULT_PIE_ON_LINUX to match the behaviour of gcc?

@jfpanisset
Copy link
Contributor

As a point of comparison, it seems that gcc 11.2.1 which is installed in the aswf-docker containers from gcc-toolset is not configured with either --enable-host-pie or --enable-default-pie :

Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/gcc-toolset-11/root/usr --mandir=/opt/rh/gcc-toolset-11/root/usr/share/man --infodir=/opt/rh/gcc-toolset-11/root/usr/share/info --with-bugurl=https://bugs.rockylinux.org/ --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-11.2.1-20220127/obj-x86_64-redhat-linux/isl-install --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux

The 2022 images were available with multiple Clang versions, from 10-14. Looking at .github/workflows/nanovdb.yml the image is specified as aswf/ci-openvdb:2022 or aswf/ci-openvdb:2024, which according to:

https://hub.docker.com/r/aswf/ci-openvdb/tags

has the 2022 tag defaulting to clang 10.0.1: this is confusing since clang 10 is well before clang added the ability to build clang with PIE enabled by default. The 2024 tag is defaulting to 2024-clang17, where clang 17.0.6 is not built with that flag.

For 2022/clang 10.0.1:

[root@a1865748f473 aswf]# llvm-config --cflags
-I/usr/local/include  -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
[root@a1865748f473 aswf]# llvm-config --cxxflags
-I/usr/local/include -std=c++14   -fno-exceptions -fno-rtti -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
[root@a1865748f473 aswf]# llvm-config --ldflags
-L/usr/local/lib

For 2022/clang 17.0.6:

[root@4f19be8f8c79 aswf]# llvm-config --cflags
-I/usr/local/include  -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
[root@4f19be8f8c79 aswf]# llvm-config --cxxflags
-I/usr/local/include -std=c++17   -fno-exceptions -funwind-tables -fno-rtti -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
[root@4f19be8f8c79 aswf]# llvm-config --ldflags
-L/usr/local/lib64

Is there a change between CUDA 11.4 (in the 2022 images) and CUDA 12.6 (in latest 2024 images) which now requires compiling with PIE which did not before?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants