Skip to content

Commit 13e1d24

Browse files
authored
Update llvm version (#416)
This updates jazzer.js to use the latest version of our LLVM fork which fixes build issues for LLVM 16
1 parent f5e07bf commit 13e1d24

2 files changed

Lines changed: 36 additions & 5 deletions

File tree

.github/workflows/run-all-tests.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ jobs:
2222
run: |
2323
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
2424
sudo apt-get install software-properties-common
25-
sudo add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main'
26-
sudo apt-get install clang-tidy-15
25+
sudo add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-16 main'
26+
sudo apt-get install clang-tidy-16
2727
sudo rm -f /usr/bin/clang-tidy
28-
sudo ln -s /usr/bin/clang-tidy-15 /usr/bin/clang-tidy
28+
sudo ln -s /usr/bin/clang-tidy-16 /usr/bin/clang-tidy
2929
- name: build fuzzer
3030
# Build the native addon so that CMake generates compile_commands.json that is needed by clang-tidy
3131
run: npm run build --workspace=@jazzer.js/fuzzer

packages/fuzzer/CMakeLists.txt

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,42 @@ set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
6969
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_JS_INC})
7070
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB})
7171

72+
# We're not sure why but sometimes systems don't end up setting LLVM_TARGET_TRIPLE used in llvm's cmake to eventually
73+
# set COMPILER_RT_DEFAULT_TARGET which is necessary for compiler-rt to build
74+
# So this will either take it from an envvar or try to set it to a sane value until we can figure out why it's broken
75+
if(NOT DEFINED ENV{COMPILER_RT_DEFAULT_TARGET_TRIPLE})
76+
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
77+
execute_process(COMMAND ${CMAKE_CXX_COMPILER} "-print-target-triple" OUTPUT_VARIABLE COMPILER_RT_DEFAULT_TARGET_TRIPLE)
78+
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
79+
execute_process(COMMAND ${CMAKE_CXX_COMPILER} "-dumpmachine" OUTPUT_VARIABLE COMPILER_RT_DEFAULT_TARGET_TRIPLE)
80+
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
81+
# pulled from https://github.com/llvm/llvm-project/blob/main/llvm/cmake/modules/GetHostTriple.cmake
82+
if( CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM64.*" )
83+
set( COMPILER_RT_DEFAULT_TARGET_TRIPLE "aarch64-pc-windows-msvc" )
84+
elseif( CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM.*" )
85+
set( COMPILER_RT_DEFAULT_TARGET_TRIPLE "armv7-pc-windows-msvc" )
86+
elseif( CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "x64" )
87+
set( COMPILER_RT_DEFAULT_TARGET_TRIPLE "x86_64-pc-windows-msvc" )
88+
elseif( CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "X86" )
89+
set( COMPILER_RT_DEFAULT_TARGET_TRIPLE "i686-pc-windows-msvc" )
90+
elseif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
91+
set( COMPILER_RT_DEFAULT_TARGET_TRIPLE "x86_64-pc-windows-msvc" )
92+
else()
93+
set( COMPILER_RT_DEFAULT_TARGET_TRIPLE "i686-pc-windows-msvc" )
94+
endif()
95+
endif()
96+
# strip whitespace because newlines from the shell calls will break the cmake call
97+
string(STRIP ${COMPILER_RT_DEFAULT_TARGET_TRIPLE} COMPILER_RT_DEFAULT_TARGET_TRIPLE)
98+
message(STATUS "COMPILER_RT_DEFAULT_TARGET_TRIPLE not set, using ${COMPILER_RT_DEFAULT_TARGET_TRIPLE}")
99+
endif()
100+
72101
# Download and build compiler-rt, which contains libfuzzer.
73102
include(ExternalProject)
74103
ExternalProject_Add(
75104
compiler-rt
76-
URL https://github.com/CodeIntelligenceTesting/llvm-project-jazzer/archive/refs/tags/2022-11-25.tar.gz
105+
URL https://github.com/CodeIntelligenceTesting/llvm-project-jazzer/archive/refs/tags/2023-04-25.tar.gz
77106
URL_HASH
78-
SHA256=e691dc9b45c35713fa67c613d352b646f30cab5d35d15abfcf77cc004a3befdb
107+
SHA256=200b32c897b1171824462706f577d7f1d6175da602eccfe570d2dceeac11d490
79108
SOURCE_SUBDIR compiler-rt
80109
CMAKE_ARGS # compiler-rt usually initializes the sanitizer runtime by means of
81110
# a pointer in the .preinit_array section; since .preinit_array
@@ -90,6 +119,8 @@ ExternalProject_Add(
90119
-DCOMPILER_RT_USE_LIBCXX=OFF
91120
# Use the same build type as the parent project.
92121
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
122+
-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=${COMPILER_RT_DEFAULT_TARGET_TRIPLE}
123+
-DLLVM_CMAKE_DIR=<SOURCE_DIR>/llvm/cmake/modules
93124
# We only need libfuzzer from the compiler-rt project.
94125
BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target
95126
${LIBFUZZER_TARGET}

0 commit comments

Comments
 (0)