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

[libc++] -DLIBCXX_CXX_ABI=system-libcxxabi not usable? #104672

Closed
h-vetinari opened this issue Aug 17, 2024 · 9 comments · Fixed by #110920
Closed

[libc++] -DLIBCXX_CXX_ABI=system-libcxxabi not usable? #104672

h-vetinari opened this issue Aug 17, 2024 · 9 comments · Fixed by #110920
Labels
cmake Build system in general and CMake in particular libc++abi libc++abi C++ Runtime Library. Not libc++. libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. release:backport

Comments

@h-vetinari
Copy link
Contributor

h-vetinari commented Aug 17, 2024

I recently noticed ba4f1e4, which is exactly the kind of build we need to do for our distribution for various reasons. I've tried this with LLVM 18.1.8 and 19.1.0-rc2, but in both cases, I get

-- Configuring done (25.4s)
CMake Error at $SRC_DIR/libcxx/cmake/Modules/HandleLibCXXABI.cmake:59 (add_library):
  No SOURCES given to target: libcxx-abi-headers-generate-private-headers
Call Stack (most recent call first):
  $SRC_DIR/libcxx/cmake/Modules/HandleLibCXXABI.cmake:135 (import_private_headers)
  $SRC_DIR/libcxx/CMakeLists.txt:511 (include)

Our build invocation roughly boils down to the following (removed some uninteresting things, but happy to elaborate);

cmake -G Ninja -B build -S runtimes \
    -DLLVM_ENABLE_RUNTIMES=libcxx;libcxxabi;libunwind \
    -DCMAKE_INSTALL_PREFIX=$PREFIX \
    -DCMAKE_BUILD_TYPE=Release \
    -DLIBCXX_ENABLE_TIME_ZONE_DATABASE=ON \
    -DLIBCXX_INCLUDE_BENCHMARKS=OFF \
    -DLIBCXX_INCLUDE_DOCS=OFF \
    -DLIBCXX_INCLUDE_TESTS=OFF \
    -DLIBCXX_HARDENING_MODE=none \
    -DLIBCXXABI_USE_LLVM_UNWINDER=OFF \
    -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
    -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 \
    -DLIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS=ON \
    -DLIBCXX_CXX_ABI=system-libcxxabi

ninja -C build cxx cxxabi unwind

I've tried removing libcxxabi from -DLLVM_ENABLE_RUNTIMES= (and the build invocation) though the result stays the same.

CC @ldionne @mgorny

@github-actions github-actions bot added libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. libc++abi libc++abi C++ Runtime Library. Not libc++. labels Aug 17, 2024
@h-vetinari
Copy link
Contributor Author

Gentle ping @ldionne

@h-vetinari
Copy link
Contributor Author

Gentle ping @mgorny @ldionne

@mgorny
Copy link
Member

mgorny commented Oct 2, 2024

Hmm, FWICS system-libcxxabi does work for us. I can't look at it in detail right now but if you're not scared of some bash, here's our ebuild: https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-libs/libcxx/libcxx-20.0.0.9999.ebuild

Note that we're doing only Linux builds, so perhaps the issue is specific to OSX. We're also passing -DLIBCXX_CXX_ABI_INCLUDE_PATHS, not sure if that's relevant. And we're only passing libcxx in -DLLVM_ENABLE_RUNTIMES, since naturally the two other libs are system libs.

@ldionne
Copy link
Member

ldionne commented Oct 2, 2024

@h-vetinari I think you're missing -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$(xcrun --show-sdk-path)/usr/include/c++/v1". However, note that even when you do that, now the build is going to start trying to re-export a list of libc++abi symbols from libc++, and obviously that only works if your system ABI library is sufficiently recent to have all of those symbols. It's kind of a brittle setup.

ldionne added a commit to ldionne/llvm-project that referenced this issue Oct 2, 2024
On Apple platforms, using system-libcxxabi as an ABI library wouldn't
work because we'd try to re-export symbols from libc++abi that the
system libc++abi.dylib might not have. Instead, only re-export those
symbols when we're using the in-tree libc++abi.

This does mean that libc++.dylib won't re-export any libc++abi symbols
when building against the system libc++abi, which could be fixed in
various ways. However, the best solution really depends on the intended
use case, so this patch doesn't try to solve that problem.

As a drive-by, also improve the diagnostic message when the user forgets
to set the LIBCXX_CXX_ABI_INCLUDE_PATHS variable, which would previously
lead to a confusing error.

Closes llvm#104672
@ldionne ldionne closed this as completed in 21da4e7 Oct 9, 2024
@EugeneZelenko EugeneZelenko added cmake Build system in general and CMake in particular and removed libc++abi libc++abi C++ Runtime Library. Not libc++. labels Oct 9, 2024
@mgorny mgorny added this to the LLVM 19.X Release milestone Nov 12, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage in LLVM Release Status Nov 12, 2024
@mgorny
Copy link
Member

mgorny commented Nov 12, 2024

Since we have another week for 19.1.4, let's backport this as well.

@mgorny mgorny reopened this Nov 12, 2024
@mgorny
Copy link
Member

mgorny commented Nov 12, 2024

/cherry-pick 5d452ab
/cherry-pick eb85139

@EugeneZelenko EugeneZelenko added libc++abi libc++abi C++ Runtime Library. Not libc++. release:backport labels Nov 12, 2024
@llvmbot
Copy link

llvmbot commented Nov 12, 2024

Failed to cherry-pick: 5d452ab

https://github.com/llvm/llvm-project/actions/runs/11800523880

Please manually backport the fix and push it to your github fork. Once this is done, please create a pull request

@mgorny
Copy link
Member

mgorny commented Nov 12, 2024

/cherry-pick 21da4e7

@llvmbot
Copy link

llvmbot commented Nov 12, 2024

/pull-request #115892

tru pushed a commit to llvmbot/llvm-project that referenced this issue Nov 18, 2024
)

On Apple platforms, using system-libcxxabi as an ABI library wouldn't
work because we'd try to re-export symbols from libc++abi that the
system libc++abi.dylib might not have. Instead, only re-export those
symbols when we're using the in-tree libc++abi.

This does mean that libc++.dylib won't re-export any libc++abi symbols
when building against the system libc++abi, which could be fixed in
various ways. However, the best solution really depends on the intended
use case, so this patch doesn't try to solve that problem.

As a drive-by, also improve the diagnostic message when the user forgets
to set the LIBCXX_CXX_ABI_INCLUDE_PATHS variable, which would previously
lead to a confusing error.

Closes llvm#104672

(cherry picked from commit 21da4e7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake Build system in general and CMake in particular libc++abi libc++abi C++ Runtime Library. Not libc++. libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. release:backport
Projects
Development

Successfully merging a pull request may close this issue.

5 participants