Compare commits

...

10 Commits

Author SHA1 Message Date
Jarred Sumner
183c4a8872 Update CompilerFlags.cmake 2024-11-22 01:11:35 -08:00
Jarred Sumner
046c15256e Update CompilerFlags.cmake 2024-11-22 01:08:55 -08:00
Jarred Sumner
9455303ecf remove quotes 2024-11-22 00:25:30 -08:00
Jarred Sumner
3f53b84269 Fix escaping issue 2024-11-22 00:21:05 -08:00
Jarred Sumner
5e8a402211 Update CompilerFlags.cmake 2024-11-21 23:38:58 -08:00
Jarred Sumner
e15cc219b8 Update CompilerFlags.cmake 2024-11-21 22:05:49 -08:00
Jarred Sumner
bbff8bc320 Update BuildBun.cmake 2024-11-21 21:58:58 -08:00
Jarred Sumner
39a2387fb9 Update CompilerFlags.cmake 2024-11-21 20:38:11 -08:00
Jarred Sumner
c76769a356 try this 2024-11-21 20:19:13 -08:00
Jarred Sumner
4f60c44799 More compiler flags 2024-11-21 19:54:02 -08:00
7 changed files with 51 additions and 21 deletions

View File

@@ -137,17 +137,19 @@ if(UNIX)
)
endif()
register_compiler_flags(
DESCRIPTION "Place each function in its own section"
-ffunction-sections ${UNIX}
/Gy ${WIN32}
)
if (NOT ENABLE_LTO)
register_compiler_flags(
DESCRIPTION "Place each function in its own section"
-ffunction-sections ${UNIX}
/Gy ${WIN32}
)
register_compiler_flags(
DESCRIPTION "Place each data item in its own section"
-fdata-sections ${UNIX}
/Gw ${WIN32}
)
register_compiler_flags(
DESCRIPTION "Place each data item in its own section"
-fdata-sections ${UNIX}
/Gw ${WIN32}
)
endif()
# having this enabled in debug mode on macOS >=14 causes libarchive to fail to configure with the error:
# > pid_t doesn't exist on this platform?
@@ -247,6 +249,17 @@ if(ENABLE_LTO)
-flto ${WIN32}
)
if (LINUX)
register_compiler_flags(
DESCRIPTION "Disable semantic interposition"
-fno-semantic-interposition
)
# Pass -emit-llvm to the compiler, and not the linker.
# It must NOT appear in any linking flags.
add_compile_options(-emit-llvm)
endif()
if(UNIX)
register_compiler_flags(
DESCRIPTION "Enable virtual tables"

View File

@@ -672,9 +672,11 @@ endfunction()
# TARGETS string[] - The targets to build from CMake
# LIBRARIES string[] - The libraries that are built
# INCLUDES string[] - The include paths
# ADDITIONAL_CMAKE_C_FLAGS string - Additional C flags
# ADDITIONAL_CMAKE_CXX_FLAGS string - Additional C++ flags
function(register_cmake_command)
set(args TARGET CWD BUILD_PATH LIB_PATH)
set(multiArgs ARGS TARGETS LIBRARIES INCLUDES)
set(multiArgs ARGS TARGETS LIBRARIES INCLUDES ADDITIONAL_CMAKE_C_FLAGS ADDITIONAL_CMAKE_CXX_FLAGS)
# Use "MAKE" instead of "CMAKE" to prevent conflicts with CMake's own CMAKE_* variables
cmake_parse_arguments(MAKE "" "${args}" "${multiArgs}" ${ARGN})
@@ -736,6 +738,16 @@ function(register_cmake_command)
endif()
endforeach()
# Handle additional C flags
if(MAKE_ADDITIONAL_CMAKE_C_FLAGS)
set(MAKE_C_FLAGS "${MAKE_C_FLAGS} ${MAKE_ADDITIONAL_CMAKE_C_FLAGS}")
endif()
# Handle additional CXX flags
if(MAKE_ADDITIONAL_CMAKE_CXX_FLAGS)
set(MAKE_CXX_FLAGS "${MAKE_CXX_FLAGS} ${MAKE_ADDITIONAL_CMAKE_CXX_FLAGS}")
endif()
if(MAKE_POSITION_INDEPENDENT_CODE AND NOT WIN32)
set(MAKE_C_FLAGS "${MAKE_C_FLAGS} -fPIC")
set(MAKE_CXX_FLAGS "${MAKE_CXX_FLAGS} -fPIC")

View File

@@ -10,7 +10,7 @@ register_repository(
# Tests fail with "BrotliDecompressionError" when LTO is enabled
# only on Linux x64 (non-baseline). It's a mystery.
if(LINUX AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|X86_64|x64|X64|amd64|AMD64" AND NOT ENABLE_BASELINE)
set(BROTLI_CMAKE_ARGS "-DCMAKE_C_FLAGS=-fno-lto")
set(BROTLI_CMAKE_C_FLAGS -fno-lto)
endif()
register_cmake_command(
@@ -25,7 +25,8 @@ register_cmake_command(
-DBROTLI_BUILD_TOOLS=OFF
-DBROTLI_EMSCRIPTEN=OFF
-DBROTLI_DISABLE_TESTS=ON
${BROTLI_CMAKE_ARGS}
INCLUDES
c/include
ADDITIONAL_CMAKE_C_FLAGS
${BROTLI_CMAKE_C_FLAGS}
)

View File

@@ -1072,7 +1072,7 @@ if(NOT BUN_CPP_ONLY)
elseif(LINUX AND NOT ABI STREQUAL "musl")
# When you use llvm-strip to do this, it doesn't delete it from the binary and instead keeps it as [LOAD #2 [R]]
# So, we must use GNU strip to do this.
set(CMAKE_STRIP_FLAGS -R .eh_frame -R .gcc_except_table)
set(CMAKE_STRIP_FLAGS -R .eh_frame -R .gcc_except_table -R .llvmbc -R .llvmcmd)
endif()
if(bunStrip)

View File

@@ -38,13 +38,14 @@ register_cmake_command(
# spawn a processes to compress instead of using the library.
-DENABLE_ZLIB=OFF
-DHAVE_ZLIB_H=ON
-DCMAKE_C_FLAGS="-I${VENDOR_PATH}/zlib"
LIB_PATH
libarchive
LIBRARIES
archive
INCLUDES
include
ADDITIONAL_CMAKE_C_FLAGS
-I${VENDOR_PATH}/zlib
)
# Must be loaded after zlib is defined

View File

@@ -8,7 +8,7 @@ register_repository(
)
if(WIN32)
set(LIBUV_CMAKE_C_FLAGS "/DWIN32 /D_WINDOWS -Wno-int-conversion")
set(LIBUV_CMAKE_C_FLAGS /DWIN32 /D_WINDOWS -Wno-int-conversion)
endif()
register_cmake_command(
@@ -20,10 +20,11 @@ register_cmake_command(
-DLIBUV_BUILD_SHARED=OFF
-DLIBUV_BUILD_TESTS=OFF
-DLIBUV_BUILD_BENCH=OFF
-DCMAKE_C_FLAGS=${LIBUV_CMAKE_C_FLAGS}
LIBRARIES
libuv WIN32
uv UNIX
INCLUDES
include
ADDITIONAL_CMAKE_C_FLAGS
${LIBUV_CMAKE_C_FLAGS}
)

View File

@@ -9,8 +9,8 @@ register_repository(
# https://gitlab.kitware.com/cmake/cmake/-/issues/25755
if(APPLE)
set(ZLIB_CMAKE_C_FLAGS "-fno-define-target-os-macros")
set(ZLIB_CMAKE_CXX_FLAGS "-fno-define-target-os-macros")
set(ZLIB_CMAKE_C_FLAGS -fno-define-target-os-macros)
set(ZLIB_CMAKE_CXX_FLAGS -fno-define-target-os-macros)
endif()
if(WIN32)
@@ -31,10 +31,12 @@ register_cmake_command(
ARGS
-DBUILD_SHARED_LIBS=OFF
-DBUILD_EXAMPLES=OFF
"-DCMAKE_C_FLAGS=${ZLIB_CMAKE_C_FLAGS}"
"-DCMAKE_CXX_FLAGS=${ZLIB_CMAKE_CXX_FLAGS}"
LIBRARIES
${ZLIB_LIBRARY}
INCLUDES
.
ADDITIONAL_CMAKE_C_FLAGS
${ZLIB_CMAKE_C_FLAGS}
ADDITIONAL_CMAKE_CXX_FLAGS
${ZLIB_CMAKE_CXX_FLAGS}
)