Skip to content

Commit fcb2f44

Browse files
Khakim-em
authored andcommitted
fix: cadical distribution on Linux (#8201)
Compile it with the same flags as other executables
1 parent 8185b79 commit fcb2f44

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

CMakeLists.txt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ option(USE_MIMALLOC "use mimalloc" ON)
55
# store all variables passed on the command line into CL_ARGS so we can pass them to the stage builds
66
# https://stackoverflow.com/a/48555098/161659
77
# MUST be done before call to 'project'
8-
# Use standard release build (discarding LEAN_CXX_EXTRA_FLAGS etc.) for stage0 by default since it is assumed to be "good", but still pass through CMake platform arguments (compiler, toolchain file, ..).
8+
# Use standard release build (discarding LEAN_EXTRA_CXX_FLAGS etc.) for stage0 by default since it is assumed to be "good", but still pass through CMake platform arguments (compiler, toolchain file, ..).
99
# Use `STAGE0_` prefix to pass variables to stage0 explicitly.
1010
get_cmake_property(vars CACHE_VARIABLES)
1111
foreach(var ${vars})
@@ -39,10 +39,14 @@ endif()
3939

4040
# Don't do anything with cadical on wasm
4141
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
42-
# On CI Linux, we source cadical from Nix instead; see flake.nix
4342
find_program(CADICAL cadical)
4443
if(NOT CADICAL)
4544
set(CADICAL_CXX c++)
45+
if (CADICAL_USE_CUSTOM_CXX)
46+
set(CADICAL_CXX ${CMAKE_CXX_COMPILER})
47+
set(CADICAL_CXXFLAGS "${LEAN_EXTRA_CXX_FLAGS}")
48+
set(CADICAL_LDFLAGS "-Wl,-rpath=\\$$ORIGIN/../lib")
49+
endif()
4650
find_program(CCACHE ccache)
4751
if(CCACHE)
4852
set(CADICAL_CXX "${CCACHE} ${CADICAL_CXX}")
@@ -57,8 +61,11 @@ if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
5761
GIT_REPOSITORY https://github.com/arminbiere/cadical
5862
GIT_TAG rel-2.1.2
5963
CONFIGURE_COMMAND ""
60-
# https://github.com/arminbiere/cadical/blob/master/BUILD.md#manual-build
61-
BUILD_COMMAND $(MAKE) -f ${CMAKE_SOURCE_DIR}/src/cadical.mk CMAKE_EXECUTABLE_SUFFIX=${CMAKE_EXECUTABLE_SUFFIX} CXX=${CADICAL_CXX} CXXFLAGS=${CADICAL_CXXFLAGS}
64+
BUILD_COMMAND $(MAKE) -f ${CMAKE_SOURCE_DIR}/src/cadical.mk
65+
CMAKE_EXECUTABLE_SUFFIX=${CMAKE_EXECUTABLE_SUFFIX}
66+
CXX=${CADICAL_CXX}
67+
CXXFLAGS=${CADICAL_CXXFLAGS}
68+
LDFLAGS=${CADICAL_LDFLAGS}
6269
BUILD_IN_SOURCE ON
6370
INSTALL_COMMAND "")
6471
set(CADICAL ${CMAKE_BINARY_DIR}/cadical/cadical${CMAKE_EXECUTABLE_SUFFIX} CACHE FILEPATH "path to cadical binary" FORCE)

script/prepare-llvm-linux.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ $CP $GLIBC/lib/libc_nonshared.a stage1/lib/glibc
5555
$CP $GLIBC/lib/libpthread_nonshared.a stage1/lib/glibc
5656
for f in $GLIBC/lib/{ld,lib{c,dl,m,rt,pthread}}-*; do b=$(basename $f); cp $f stage1/lib/glibc/${b%-*}.so; done
5757
OPTIONS=()
58-
echo -n " -DLEAN_STANDALONE=ON"
58+
# We build cadical using the custom toolchain on Linux to avoid glibc versioning issues
59+
echo -n " -DLEAN_STANDALONE=ON -DCADICAL_USE_CUSTOM_CXX=ON"
5960
echo -n " -DCMAKE_CXX_COMPILER=$PWD/llvm-host/bin/clang++ -DLEAN_CXX_STDLIB='-Wl,-Bstatic -lc++ -lc++abi -Wl,-Bdynamic'"
6061
echo -n " -DLEAN_EXTRA_CXX_FLAGS='--sysroot $PWD/llvm -idirafter $GLIBC_DEV/include ${EXTRA_FLAGS:-}'"
6162
# use target compiler directly when not cross-compiling

src/cadical.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ CXX ?= c++
44
$(CXX) -std=c++11 -O3 -DNDEBUG -DNBUILD $(CXXFLAGS) -c $< -o $@
55

66
../../cadical$(CMAKE_EXECUTABLE_SUFFIX): $(patsubst src/%.cpp,%.o,$(shell ls src/*.cpp | grep -v mobical))
7-
$(CXX) -o $@ $^
7+
$(CXX) -o $@ $^ $(LDFLAGS)

0 commit comments

Comments
 (0)