Skip to content

Commit 7de430f

Browse files
authored
expat: Fix build for new fuzzer xml_lpm_fuzzer (#13015)
Related: - libexpat/libexpat#950 - libexpat/libexpat#961 - google/libprotobuf-mutator#274 - #13016 --------- Signed-off-by: Sebastian Pipping <[email protected]>
1 parent 77b6574 commit 7de430f

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

projects/expat/Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright 2016 Google Inc.
2+
# Copyright 2025 Sebastian Pipping <[email protected]>
23
#
34
# Licensed under the Apache License, Version 2.0 (the "License");
45
# you may not use this file except in compliance with the License.
@@ -15,7 +16,13 @@
1516
################################################################################
1617

1718
FROM gcr.io/oss-fuzz-base/base-builder
18-
RUN apt-get update && apt-get install -y cmake docbook2x make
19+
RUN apt-get update && apt-get install -y \
20+
cmake \
21+
libprotobuf-dev:amd64 \
22+
libprotobuf-dev:i386 \
23+
libstdc++-9-dev:i386 \
24+
make \
25+
protobuf-compiler
1926

2027
RUN git clone --depth 1 https://github.com/libexpat/libexpat expat
2128
WORKDIR expat

projects/expat/build.sh

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash -eu
22
# Copyright 2016 Google Inc.
3+
# Copyright 2025 Sebastian Pipping <[email protected]>
34
#
45
# Licensed under the Apache License, Version 2.0 (the "License");
56
# you may not use this file except in compliance with the License.
@@ -15,14 +16,32 @@
1516
#
1617
################################################################################
1718

19+
# NOTE: We need to drop -stdlib=libc++ to not get (pages of) link errors when
20+
# linking against system Protobuf that is linked against GCC's libstdc++
21+
# rather than Clang's own libstdc++
22+
CXXFLAGS="${CXXFLAGS/-stdlib=libc++/ }"
23+
24+
# NOTE: Without -static-libstdc++, the bad build checker in base-runner
25+
# will fail with output:
26+
# > error while loading shared libraries: libstdc++.so.6:
27+
# > cannot open shared object file: No such file or directory
28+
# The addition of -Wno-unused-command-line-argument silences Clang's
29+
# misleading output on argument -static-libstdc++ appearing as unused.
30+
CXXFLAGS="${CXXFLAGS} -static-libstdc++ -Wno-unused-command-line-argument"
31+
1832
: ${LD:="${CXX}"}
1933
: ${LDFLAGS:="${CXXFLAGS}"} # to make sure we link with sanitizer runtime
2034

2135
cmake_args=(
2236
# Specific to Expat
37+
-DEXPAT_BUILD_DOCS=OFF
38+
-DEXPAT_BUILD_EXAMPLES=OFF
2339
-DEXPAT_BUILD_FUZZERS=ON
40+
-DEXPAT_BUILD_TESTS=OFF
41+
-DEXPAT_BUILD_TOOLS=OFF
2442
-DEXPAT_OSSFUZZ_BUILD=ON
2543
-DEXPAT_SHARED_LIBS=OFF
44+
-DProtobuf_USE_STATIC_LIBS=ON
2645

2746
# C compiler
2847
-DCMAKE_C_COMPILER="${CC}"
@@ -48,14 +67,11 @@ for fuzzer in fuzz/*;
4867
do
4968
cp $fuzzer $OUT
5069
fuzzer_name=$(basename $fuzzer)
51-
if [[ ${fuzzer_name} =~ ^.*UTF-16$ ]];
52-
then
70+
if [[ ${fuzzer_name} =~ ^.*UTF-16$ ]]; then
5371
cp $SRC/xml_UTF_16.dict $OUT/${fuzzer_name}.dict
54-
elif [[ ${fuzzer_name} =~ ^.*UTF-16LE$ ]];
55-
then
72+
elif [[ ${fuzzer_name} =~ ^.*UTF-16LE$ ]]; then
5673
cp $SRC/xml_UTF_16LE.dict $OUT/${fuzzer_name}.dict
57-
elif [[ ${fuzzer_name} =~ ^.*UTF-16BE$ ]];
58-
then
74+
elif [[ ${fuzzer_name} =~ ^.*UTF-16BE$ ]]; then
5975
cp $SRC/xml_UTF_16BE.dict $OUT/${fuzzer_name}.dict
6076
else
6177
cp $SRC/xml.dict $OUT/${fuzzer_name}.dict

0 commit comments

Comments
 (0)