Skip to content

Commit 7472bd5

Browse files
authored
[Tests] Explicitly link test_binary.bin against in-tree libc++ (#19)
1 parent 97723fc commit 7472bd5

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

lldb/unittests/DIL/DILTests.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,11 +1571,11 @@ TEST_F(EvalTest, TestCxxStaticCast) {
15711571

15721572
// Cast to nullptr.
15731573
EXPECT_THAT(Eval("static_cast<nullptr_t>((int)0)"),
1574-
IsError("static_cast from 'int' to 'nullptr_t' (canonically "
1574+
IsError("static_cast from 'int' to 'std::__1::nullptr_t' (canonically "
15751575
"referred to as 'std::nullptr_t')"
15761576
" is not allowed"));
15771577
EXPECT_THAT(Eval("static_cast<nullptr_t>((void*)0)"),
1578-
IsError("static_cast from 'void *' to 'nullptr_t' (canonically "
1578+
IsError("static_cast from 'void *' to 'std::__1::nullptr_t' (canonically "
15791579
"referred to as 'std::nullptr_t')"
15801580
" is not allowed"));
15811581

@@ -1797,18 +1797,17 @@ TEST_F(EvalTest, TestCxxReinterpretCast) {
17971797
Eval("reinterpret_cast<void*>(nullptr)"),
17981798
IsError("reinterpret_cast from 'std::nullptr_t' to 'void *' is not "
17991799
"allowed"));
1800-
GTEST_SKIP() << "Unknown error string mismatch";
18011800
EXPECT_THAT(
18021801
Eval("reinterpret_cast<nullptr_t>(ptr)"),
1803-
IsError("reinterpret_cast from 'int *' to 'nullptr_t' "
1802+
IsError("reinterpret_cast from 'int *' to 'std::__1::nullptr_t' "
18041803
"(canonically referred to as 'std::nullptr_t') is not allowed"));
18051804
EXPECT_THAT(
18061805
Eval("reinterpret_cast<nullptr_t>(0)"),
1807-
IsError("reinterpret_cast from 'int' to 'nullptr_t' "
1806+
IsError("reinterpret_cast from 'int' to 'std::__1::nullptr_t' "
18081807
"(canonically referred to as 'std::nullptr_t') is not allowed"));
18091808
EXPECT_THAT(
18101809
Eval("reinterpret_cast<nullptr_t>(nullptr)"),
1811-
IsError("reinterpret_cast from 'std::nullptr_t' to 'nullptr_t' "
1810+
IsError("reinterpret_cast from 'std::nullptr_t' to 'std::__1::nullptr_t' "
18121811
"(canonically referred to as 'std::nullptr_t') is not allowed"));
18131812
}
18141813

lldb/unittests/DIL/Inputs/CMakeLists.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@ if ("libcxx" IN_LIST LLVM_ENABLE_RUNTIMES)
1010
else()
1111
set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
1212
set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
13-
set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${CMAKE_BINARY_DIR}/include/c++/v1")
13+
endif()
14+
15+
if(DEFINED LIBCXX_GENERATED_INCLUDE_TARGET_DIR)
16+
set(INCLUDE_TARGET_DIR_OPTION "-cxx-isystem" "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}")
1417
endif()
1518

1619
get_target_property(EXE_PATH DILTests RUNTIME_OUTPUT_DIRECTORY)
1720
add_custom_command(
1821
OUTPUT test_binary.bin
1922
COMMAND $<TARGET_FILE:clang> ${CMAKE_CURRENT_SOURCE_DIR}/test_binary.cc
2023
-O0 -g -std=c++17 -fuse-ld=lld -B$<TARGET_FILE:lld>
21-
-L ${LIBCXX_LIBRARY_DIR} -stdlib=libc++ -lc++
22-
-I ${LIBCXX_GENERATED_INCLUDE_DIR}
23-
-I ${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}
24+
-nostdlib++ -nostdinc++ -cxx-isystem ${LIBCXX_GENERATED_INCLUDE_DIR}
25+
${INCLUDE_TARGET_DIR_OPTION}
26+
-L${LIBCXX_LIBRARY_DIR} -Wl,-rpath,${LIBCXX_LIBRARY_DIR} -lc++
2427
-o ${EXE_PATH}/Inputs/test_binary.bin
2528
DEPENDS test_binary.cc clang lld
2629
)

0 commit comments

Comments
 (0)