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

Make building for clang/libc++ simpler #531

Closed
1 of 3 tasks
kristjanvalur opened this issue Apr 28, 2021 · 3 comments
Closed
1 of 3 tasks

Make building for clang/libc++ simpler #531

kristjanvalur opened this issue Apr 28, 2021 · 3 comments

Comments

@kristjanvalur
Copy link

Description

I need to compile on Linux to link with a project that uses clang and libc++ (rather than gcc and libstdc++)
It took me a few hours of googling and trial and error to figure out the solution.

Either it could be documented or made simpler via cmake config

When does the problem happen

  • During build
  • During run-time
  • When capturing a hard crash

Environment
Ubuntu 18, with cmake 3.30

Steps To Reproduce

To successfully compile sentry-native, the following needs to be done:

  1. Install prerequisites
  • zlib-dev
  • libssl-dev
  • clang
  • libc++-dev
  • libc++abli-dev
  1. run cmake with the following extra options:
    -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_EXE_LINKER_FLAGS="-stdlib=libc++"
@Swatinem
Copy link
Member

I think this is rather something that should be documented on the libc++ side, as I bet this affects all c++ projects essentially.

@kristjanvalur
Copy link
Author

kristjanvalur commented Apr 29, 2021 via email

@madebr
Copy link
Contributor

madebr commented Jul 14, 2021

The easiest way to address your problem would be to use cmake toolchain files.

e.g. create a file names toolchain-clang-libcxx.cmake:

find_program(CMAKE_C_COMPILER NAMES clang)
find_program(CMAKE_CXX_COMPILER NAMES clang++)

set(CMAKE_CXX_FLAGS_INIT "-stdlib=libc++")
set(CMAKE_EXE_LINKER_FLAGS_INIT "-stdlib=libc++")
set(CMAKE_STARED_LINKER_FLAGS_INIT "-stdlib=libc++")

and build the project with:

cmake -S $path_to_sentry_native -B build -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain-clang-libcxx.cmake
cmake --build build --parallel

No changes need to be done to sentry-native's cmake scripts.

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

No branches or pull requests

5 participants