11#! /bin/bash -eu
22# Copyright 2016 Google Inc.
3+ # Copyright 2025 Sebastian Pipping <sebastian@pipping.org>
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.
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
2135cmake_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/*;
4867do
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