mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-17 00:10:28 +00:00
[libc] Replace -nostdlib++ flag when building with gcc and add placement new operator to HermeticTestUtils.cpp. (#78906)
`-nostdlib++` is a clang-only flag. Replacing it with `-nostdlib` when building with gcc.
This commit is contained in:
parent
7117a4e840
commit
029bfd6329
@ -62,3 +62,6 @@ message(STATUS "Compiler features available: ${AVAILABLE_COMPILER_FEATURES}")
|
||||
|
||||
# clang-8+, gcc-12+
|
||||
check_cxx_compiler_flag("-ftrivial-auto-var-init=pattern" LIBC_CC_SUPPORTS_PATTERN_INIT)
|
||||
|
||||
# clang-6+, gcc-13+
|
||||
check_cxx_compiler_flag("-nostdlib++" LIBC_CC_SUPPORTS_NOSTDLIBPP)
|
||||
|
@ -435,6 +435,13 @@ function(add_libc_fuzzer target_name)
|
||||
|
||||
endfunction(add_libc_fuzzer)
|
||||
|
||||
# Get libgcc_s to be used in hermetic and integration tests.
|
||||
if(NOT LIBC_CC_SUPPORTS_NOSTDLIBPP)
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=libgcc_s.so.1
|
||||
OUTPUT_VARIABLE LIBGCC_S_LOCATION)
|
||||
string(STRIP ${LIBGCC_S_LOCATION} LIBGCC_S_LOCATION)
|
||||
endif()
|
||||
|
||||
# DEPRECATED: Use add_hermetic_test instead.
|
||||
#
|
||||
# Rule to add an integration test. An integration test is like a unit test
|
||||
@ -564,8 +571,13 @@ function(add_integration_test test_name)
|
||||
|
||||
if(LIBC_TARGET_ARCHITECTURE_IS_GPU)
|
||||
target_link_options(${fq_build_target_name} PRIVATE -nostdlib -static)
|
||||
else()
|
||||
elseif(LIBC_CC_SUPPORTS_NOSTDLIBPP)
|
||||
target_link_options(${fq_build_target_name} PRIVATE -nolibc -nostartfiles -nostdlib++ -static)
|
||||
else()
|
||||
# Older version of gcc does not support `nostdlib++` flag. We use
|
||||
# `nostdlib` and link against libgcc_s, which cannot be linked statically.
|
||||
target_link_options(${fq_build_target_name} PRIVATE -nolibc -nostartfiles -nostdlib)
|
||||
list(APPEND link_libraries ${LIBGCC_S_LOCATION})
|
||||
endif()
|
||||
target_link_libraries(
|
||||
${fq_build_target_name}
|
||||
@ -741,8 +753,13 @@ function(add_libc_hermetic_test test_name)
|
||||
|
||||
if(LIBC_TARGET_ARCHITECTURE_IS_GPU)
|
||||
target_link_options(${fq_build_target_name} PRIVATE -nostdlib -static)
|
||||
else()
|
||||
elseif(LIBC_CC_SUPPORTS_NOSTDLIBPP)
|
||||
target_link_options(${fq_build_target_name} PRIVATE -nolibc -nostartfiles -nostdlib++ -static)
|
||||
else()
|
||||
# Older version of gcc does not support `nostdlib++` flag. We use
|
||||
# `nostdlib` and link against libgcc_s, which cannot be linked statically.
|
||||
target_link_options(${fq_build_target_name} PRIVATE -nolibc -nostartfiles -nostdlib)
|
||||
list(APPEND link_libraries ${LIBGCC_S_LOCATION})
|
||||
endif()
|
||||
target_link_libraries(
|
||||
${fq_build_target_name}
|
||||
|
@ -104,6 +104,8 @@ void *__dso_handle = nullptr;
|
||||
|
||||
} // extern "C"
|
||||
|
||||
void *operator new(unsigned long size, void *ptr) { return ptr; }
|
||||
|
||||
void *operator new(size_t size) { return malloc(size); }
|
||||
|
||||
void *operator new[](size_t size) { return malloc(size); }
|
||||
@ -113,3 +115,5 @@ void operator delete(void *) {
|
||||
// we just trap here to catch any such accidental usages.
|
||||
__builtin_trap();
|
||||
}
|
||||
|
||||
void operator delete(void *ptr, size_t size) { __builtin_trap(); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user