Skip to content

Commit 2dcf442

Browse files
hartworkvitalybuka
authored andcommitted
Pin external libexpat and libxml2 for CI stability
.. for a stable build, unless -DLIB_PROTO_MUTATOR_EXAMPLES_USE_LATEST=ON is passed so that OSS-Fuzz has a chance to keep fuzzing the very latest. The other two calls to `ExternalProject_Add` for GoogleTest and Protobuf were pinned already. List of Git tags for libexpat and libxml2: - https://github.com/libexpat/libexpat/tags - https://gitlab.gnome.org/GNOME/libxml2/-/tags Related code in OSS-Fuzz: https://github.com/google/oss-fuzz/blob/22bf164795d077841e099c7a70b595b15158b36f/projects/libprotobuf-mutator/build.sh#L27 Signed-off-by: Sebastian Pipping <[email protected]>
1 parent 2075b6c commit 2dcf442

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ option(LIB_PROTO_MUTATOR_EXAMPLES "Enable examples building" ON)
2323
option(LIB_PROTO_MUTATOR_DOWNLOAD_PROTOBUF
2424
"Automatically download working protobuf" OFF)
2525
option(LIB_PROTO_MUTATOR_WITH_ASAN "Enable address sanitizer" OFF)
26+
option(LIB_PROTO_MUTATOR_EXAMPLES_USE_LATEST "Use latest libexpat/libxml2 for expat_example/libxml2_example" OFF)
2627
set(PKG_CONFIG_PATH "share/pkgconfig" CACHE STRING "Directory to install pkgconfig file")
2728
set(LIB_PROTO_MUTATOR_FUZZER_LIBRARIES "" CACHE STRING "Fuzzing engine libs")
2829

cmake/external/expat.cmake

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,20 @@ if(DEFINED CMAKE_C_COMPILER_LAUNCHER AND DEFINED CMAKE_CXX_COMPILER_LAUNCHER)
3737
set(EXPAT_CXX_COMPILER "${CMAKE_CXX_COMPILER_LAUNCHER} ${EXPAT_CXX_COMPILER}")
3838
endif()
3939

40+
# NOTE: Fuzzer "expat_example" is being used for actual fuzzing in OSS-Fuzz.
41+
# We want a rock-solid build by default (hence the pinning to a
42+
# specific version) but also be fuzzing the very latest in OSS-Fuzz.
43+
if (LIB_PROTO_MUTATOR_EXAMPLES_USE_LATEST)
44+
set(EXPAT_GIT_TAG "master")
45+
else()
46+
set(EXPAT_GIT_TAG "R_2_6_4")
47+
endif()
48+
4049
include (ExternalProject)
4150
ExternalProject_Add(${EXPAT_TARGET}
4251
PREFIX ${EXPAT_TARGET}
4352
GIT_REPOSITORY https://github.com/libexpat/libexpat
44-
GIT_TAG master
53+
GIT_TAG ${EXPAT_GIT_TAG}
4554
UPDATE_COMMAND ""
4655
CONFIGURE_COMMAND cd ${EXPAT_SRC_DIR} && ./buildconf.sh && ./configure
4756
--prefix=${EXPAT_INSTALL_DIR}

cmake/external/libxml2.cmake

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,20 @@ foreach(lib IN LISTS LIBXML2_LIBRARIES)
3030
add_dependencies(${lib} ${LIBXML2_TARGET})
3131
endforeach(lib)
3232

33+
# NOTE: Fuzzer "libxml2_example" is being used for actual fuzzing in OSS-Fuzz.
34+
# We want a rock-solid build by default (hence the pinning to a
35+
# specific version) but also be fuzzing the very latest in OSS-Fuzz.
36+
if (LIB_PROTO_MUTATOR_EXAMPLES_USE_LATEST)
37+
set(LIBXML2_GIT_TAG "master")
38+
else()
39+
set(LIBXML2_GIT_TAG "v2.13.6")
40+
endif()
41+
3342
include (ExternalProject)
3443
ExternalProject_Add(${LIBXML2_TARGET}
3544
PREFIX ${LIBXML2_TARGET}
3645
GIT_REPOSITORY GIT_REPOSITORY https://gitlab.gnome.org/GNOME/libxml2
37-
GIT_TAG master
46+
GIT_TAG ${LIBXML2_GIT_TAG}
3847
UPDATE_COMMAND ""
3948
CMAKE_CACHE_ARGS -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
4049
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}

0 commit comments

Comments
 (0)