Skip to content

Commit 3530f01

Browse files
committed
fix
1 parent 1d25c02 commit 3530f01

File tree

6 files changed

+26
-25
lines changed

6 files changed

+26
-25
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ jobs:
376376
fi
377377
# contortion to support empty OPTIONS with old macOS bash
378378
cmake .. --preset ${{ matrix.CMAKE_PRESET || 'release' }} -B . ${{ matrix.CMAKE_OPTIONS }} ${OPTIONS[@]+"${OPTIONS[@]}"} -DLEAN_INSTALL_PREFIX=$PWD/..
379-
time make -j$NPROC
379+
time make -j$NPROC VERBOSE=1
380380
- name: Install
381381
run: |
382382
make -C build install

nix/bootstrap.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ lib.warn "The Nix-based build is deprecated" rec {
6868
build = args: buildLeanPackage.override {
6969
lean = prevStage;
7070
leanc = writeShellScriptBin "leanc" ''
71-
${stdenv.cc}/bin/cc -O3 -DNDEBUG -fstack-clash-protection -fPIC -fvisibility=hidden -I${lean-bin-tools-unwrapped}/include "$@"
71+
${stdenv.cc}/bin/cc -O3 -DNDEBUG -fstack-clash-protection -fPIC -fvisibility=hidden -fwrapv -I${lean-bin-tools-unwrapped}/include "$@"
7272
'';
7373
# use same stage for retrieving dependencies
7474
lean-leanDeps = stage0;

src/CMakeLists.txt

+16-16
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ endif()
3131

3232
set(LEAN_EXTRA_LINKER_FLAGS "" CACHE STRING "Additional flags used by the linker")
3333
set(LEAN_EXTRA_CXX_FLAGS "" CACHE STRING "Additional flags used by the C++ compiler")
34-
set(LEAN_TEST_VARS "LEAN_CC_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER} LEAN_CC=${CMAKE_C_COMPILER}" CACHE STRING "Additional environment variables used when running tests")
34+
set(LEAN_TEST_VARS "LEAN_CC=${CMAKE_C_COMPILER}" CACHE STRING "Additional environment variables used when running tests")
3535

3636
if (NOT CMAKE_BUILD_TYPE)
3737
message(STATUS "No build type selected, default to Release")
@@ -572,6 +572,21 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
572572
string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--whole-archive -lleanmanifest -Wl,--no-whole-archive")
573573
endif()
574574

575+
# use Bash version for building stage 0 and 1, use Lean version afterwards
576+
if(${STAGE} EQUAL 0)
577+
configure_file("${LEAN_SOURCE_DIR}/bin/leanc.in" "${CMAKE_BINARY_DIR}/bin/leanc${CMAKE_EXECUTABLE_SUFFIX}" @ONLY)
578+
set(LEANC "${CMAKE_BINARY_DIR}/bin/leanc")
579+
else()
580+
set(LEANC "${PREV_STAGE}/bin/leanc")
581+
endif()
582+
583+
string(REPLACE "ROOT" "${CMAKE_BINARY_DIR}" LEANC_CC "${LEANC_CC}")
584+
string(REPLACE "ROOT" "${CMAKE_BINARY_DIR}" LEANC_INTERNAL_FLAGS "${LEANC_INTERNAL_FLAGS}")
585+
string(REPLACE "ROOT" "${CMAKE_BINARY_DIR}" LEANC_INTERNAL_LINKER_FLAGS "${LEANC_INTERNAL_LINKER_FLAGS}")
586+
587+
string(APPEND LEANC_OPTS " ${LEANC_EXTRA_CC_FLAGS} ${LEANC_INTERNAL_FLAGS}")
588+
set(LINK_OPTS "${LEANC_INTERNAL_LINKER_FLAGS} -L${CMAKE_BINARY_DIR}/lib/lean ${LEAN_EXTRA_LINKER_FLAGS}")
589+
575590
if(${STAGE} GREATER 1)
576591
# reuse C++ parts, which don't change
577592
add_library(leanrt_initial-exec STATIC IMPORTED)
@@ -732,14 +747,6 @@ if(PREV_STAGE)
732747
DEPENDS update-stage0)
733748
endif()
734749

735-
# use Bash version for building stage 0 and 1, use Lean version afterwards
736-
if(${STAGE} EQUAL 0)
737-
configure_file("${LEAN_SOURCE_DIR}/bin/leanc.in" "${CMAKE_BINARY_DIR}/bin/leanc${CMAKE_EXECUTABLE_SUFFIX}" @ONLY)
738-
set(LEANC "${CMAKE_BINARY_DIR}/bin/leanc")
739-
else()
740-
set(LEANC "${PREV_STAGE}/bin/leanc")
741-
endif()
742-
743750
if(${STAGE} GREATER 0 AND EXISTS ${LEAN_SOURCE_DIR}/Leanc.lean AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
744751
configure_file("${LEAN_SOURCE_DIR}/Leanc.lean" "${CMAKE_BINARY_DIR}/leanc/Leanc.lean" @ONLY)
745752
add_custom_target(leanc ALL
@@ -798,13 +805,6 @@ if(LEAN_INSTALL_PREFIX)
798805
set(CMAKE_INSTALL_PREFIX "${LEAN_INSTALL_PREFIX}/lean-${LEAN_VERSION_STRING}${LEAN_INSTALL_SUFFIX}")
799806
endif()
800807

801-
string(REPLACE "ROOT" "${CMAKE_BINARY_DIR}" LEANC_CC "${LEANC_CC}")
802-
string(REPLACE "ROOT" "${CMAKE_BINARY_DIR}" LEANC_INTERNAL_FLAGS "${LEANC_INTERNAL_FLAGS}")
803-
string(REPLACE "ROOT" "${CMAKE_BINARY_DIR}" LEANC_INTERNAL_LINKER_FLAGS "${LEANC_INTERNAL_LINKER_FLAGS}")
804-
805-
string(APPEND LEANC_OPTS " ${LEANC_EXTRA_CC_FLAGS} ${LEANC_INTERNAL_FLAGS}")
806-
set(LINK_OPTS "${LEANC_INTERNAL_LINKER_FLAGS} ${LEAN_EXTRA_LINKER_FLAGS} -L${CMAKE_BINARY_DIR}/lib/lean")
807-
808808
# Escape for `make`. Yes, twice.
809809
string(REPLACE "$" "\\\$$" CMAKE_EXE_LINKER_FLAGS_MAKE "${CMAKE_EXE_LINKER_FLAGS}")
810810
string(REPLACE "$" "$$" CMAKE_EXE_LINKER_FLAGS_MAKE_MAKE "${CMAKE_EXE_LINKER_FLAGS_MAKE}")

src/stdlib.make.in

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ ifeq "${CMAKE_SYSTEM_NAME}" "Windows"
7777
@rm -f $@
7878
"${LEANC}" -shared -o $@ \
7979
-Wl,--whole-archive ${CMAKE_BINARY_DIR}/lib/lean/libInit.a.export ${CMAKE_BINARY_DIR}/lib/lean/libStd.a.export ${CMAKE_BINARY_DIR}/runtime/libleanrt_initial-exec.a -Wl,--no-whole-archive \
80-
-Wl,--out-implib,${CMAKE_BINARY_DIR}/lib/lean/libInit_shared.dll.a ${TOOLCHAIN_SHARED_LINKER_FLAGS} ${LEANC_OPTS}
80+
-Wl,--out-implib,${CMAKE_BINARY_DIR}/lib/lean/libInit_shared.dll.a ${TOOLCHAIN_SHARED_LINKER_FLAGS} ${LEANC_OPTS} ${LINK_OPTS}
8181
else
8282
# create empty library on platforms without restrictive symbol limits; avoids costly indirections and troubles with cross-library exceptions
8383
"${LEANC}" -shared -o $@ ${LIB}/temp/empty.c ${INIT_SHARED_LINKER_FLAGS} ${TOOLCHAIN_SHARED_LINKER_FLAGS} ${LEANC_OPTS} ${LINK_OPTS}
@@ -94,7 +94,7 @@ ifeq "${CMAKE_SYSTEM_NAME}" "Windows"
9494
# "half-way point" DLL to avoid symbol limit
9595
# include Lean.Meta.WHNF and leancpp except for `initialize.cpp`
9696
"${LEANC}" -shared -o ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libleanshared_1${CMAKE_SHARED_LIBRARY_SUFFIX} \
97-
${LIB}/temp/Lean/Meta/WHNF.o.export -Wl,--start-group ${LIB}/lean/libLean.a.export -Wl,--whole-archive ${LIB}/temp/libleancpp_1.a -Wl,--no-whole-archive -Wl,--end-group -lInit_shared -Wl,--out-implib,${LIB}/lean/libleanshared_1.dll.a ${LEANSHARED_LINKER_FLAGS} ${TOOLCHAIN_SHARED_LINKER_FLAGS} ${LEANC_OPTS} -Wl,-Map=${LIB}/temp/libleanshared_1.map
97+
${LIB}/temp/Lean/Meta/WHNF.o.export -Wl,--start-group ${LIB}/lean/libLean.a.export -Wl,--whole-archive ${LIB}/temp/libleancpp_1.a -Wl,--no-whole-archive -Wl,--end-group -lInit_shared -Wl,--out-implib,${LIB}/lean/libleanshared_1.dll.a ${LEANSHARED_LINKER_FLAGS} ${TOOLCHAIN_SHARED_LINKER_FLAGS} ${LEANC_OPTS} ${LINK_OPTS} -Wl,-Map=${LIB}/temp/libleanshared_1.map
9898
# now delete included symbols from libLean.a
9999
cp ${LIB}/lean/libLean.a.export ${LIB}/temp/diff.a
100100
sed -En 's/.*\s(\S*\.o\.export):.*/\1/p' ${LIB}/temp/libleanshared_1.map > ${LIB}/temp/diff.a.in
@@ -106,7 +106,7 @@ ifeq "${CMAKE_SYSTEM_NAME}" "Windows"
106106
-Wl,--whole-archive ${LIB}/temp/diff.a ${LIB}/temp/libleanshell.a ${LIB}/temp/libleaninitialize.a -Wl,--no-whole-archive -lleanshared_1 -lInit_shared -Wl,--out-implib,${LIB}/lean/libleanshared.dll.a ${LEANSHARED_LINKER_FLAGS} ${TOOLCHAIN_SHARED_LINKER_FLAGS} ${LEANC_OPTS} ${LINK_OPTS}
107107
else
108108
# create empty library on platforms without restrictive symbol limits; avoids costly indirections and troubles with cross-library exceptions
109-
"${LEANC}" -shared -o ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libleanshared_1${CMAKE_SHARED_LIBRARY_SUFFIX} ${LIB}/temp/empty.c ${LEANSHARED_1_LINKER_FLAGS} ${TOOLCHAIN_SHARED_LINKER_FLAGS} ${LEANC_OPTS}
109+
"${LEANC}" -shared -o ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libleanshared_1${CMAKE_SHARED_LIBRARY_SUFFIX} ${LIB}/temp/empty.c ${LEANSHARED_1_LINKER_FLAGS} ${TOOLCHAIN_SHARED_LINKER_FLAGS} ${LEANC_OPTS} ${LINK_OPTS}
110110
ifeq "${CMAKE_SYSTEM_NAME}" "Darwin"
111111
"${LEANC}" -shared -o $@ \
112112
${LIB}/temp/Lean.*o.export -Wl,-force_load,${LIB}/temp/libleanshell.a -lInit -lStd -lLean -lleancpp ${CMAKE_BINARY_DIR}/runtime/libleanrt_initial-exec.a ${LEANSHARED_LINKER_FLAGS} ${TOOLCHAIN_SHARED_LINKER_FLAGS} ${LEANC_OPTS} ${LINK_OPTS}

stage0/src/CMakeLists.txt

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

stage0/src/stdlib.make.in

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)