Skip to content

Commit e409c0c

Browse files
authored
Restore and verify GCC compatibility (#177)
* Declare intermediate targets as manual Makes it easier to skip targets, such as those using FuzzedDataProvider when using gcc as CC. * Restore compatibility with gcc for replay engine Using the weak attribute together with an explicitly undefined symbol should still work on macOS, see: https://stackoverflow.com/a/34983229/297261 * Update Jazzer for gcc compatibility * Skip FuzzedDataProvider test with non-clang CC * Run regression tests with GCC * Run regression tests in CI on macOS Excludes the tests in //examples/java, which require further fixes to find libjvm.dylib. * Make launchers compatible with macOS Implements the missing readlink -f command in Python.
1 parent b2b3efd commit e409c0c

11 files changed

Lines changed: 44 additions & 9 deletions

File tree

.github/workflows/bazel_test.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,26 @@ jobs:
114114
bazel test --verbose_failures --test_output=all \
115115
--build_tag_filters=fuzz-test --config=${{ matrix.config }} \
116116
//examples/java/...
117+
regression_tests_gcc:
118+
name: Regression tests (GCC)
119+
runs-on: ubuntu-latest
120+
timeout-minutes: 30
121+
steps:
122+
- name: Checkout repository
123+
uses: actions/checkout@v2
124+
- name: Run regression tests with GCC
125+
run: |
126+
bazel test --action_env=CC=gcc --action_env=CXX=g++ \
127+
--verbose_failures --test_output=all \
128+
//examples/...
129+
regression_tests_mac:
130+
name: Regression tests (macOS)
131+
runs-on: macos-latest
132+
timeout-minutes: 30
133+
steps:
134+
- name: Checkout repository
135+
uses: actions/checkout@v2
136+
- name: Run regression tests on macOS
137+
run: |
138+
bazel test --verbose_failures --test_output=all \
139+
-- //examples/... -//examples/java:all

BUILD

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
15+
config_setting(
16+
name = "clang",
17+
flag_values = {"@bazel_tools//tools/cpp:compiler": "clang"},
18+
)

examples/BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ cc_fuzz_test(
5858
cc_fuzz_test(
5959
name = "fuzzed_data_provider_fuzz_test",
6060
srcs = ["fuzzed_data_provider_fuzz_test.cc"],
61+
target_compatible_with = select({
62+
"//:clang": [],
63+
"//conditions:default": ["@platforms//:incompatible"],
64+
}),
6165
)
6266

6367
cc_fuzz_test(

fuzzing/engines/honggfuzz_launcher.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
command_line="$(readlink -f ${HONGGFUZZ_PATH})"
15+
command_line="$(python3 -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' ${HONGGFUZZ_PATH})"
1616
command_line+=("--workspace=${FUZZER_OUTPUT_ROOT}")
1717

1818
if [[ -n "${FUZZER_SEED_CORPUS_DIR}" ]]; then

fuzzing/engines/jazzer_launcher.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# engine. The launch configuration is supplied by the launcher script through
1717
# environment variables.
1818

19-
command_line=("$(readlink -f ${FUZZER_BINARY})")
19+
command_line=("$(python3 -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' ${FUZZER_BINARY})")
2020

2121
# libFuzzer flags (compatible with Jazzer).
2222

fuzzing/engines/libfuzzer_launcher.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# libFuzzer engine. The launch configuration is supplied by the launcher
1717
# script through environment variables.
1818

19-
command_line=("$(readlink -f ${FUZZER_BINARY})")
19+
command_line=("$(python3 -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' ${FUZZER_BINARY})")
2020

2121
# libFuzzer flags.
2222

fuzzing/engines/replay_launcher.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if (( ! FUZZER_IS_REGRESSION )); then
1616
echo "NOTE: Non-regression mode is not supported by the replay engine."
1717
fi
1818

19-
command_line=("$(readlink -f ${FUZZER_BINARY})")
19+
command_line=("$(python3 -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' ${FUZZER_BINARY})")
2020
if [[ -n "${FUZZER_SEED_CORPUS_DIR}" ]]; then
2121
command_line+=("${FUZZER_SEED_CORPUS_DIR}")
2222
fi

fuzzing/private/fuzz_test.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def cc_fuzz_test(
174174
# instrumented configuration.
175175
raw_binary_name = name + "_raw_"
176176
binary_kwargs.setdefault("deps", []).append(engine)
177+
binary_kwargs.setdefault("tags", []).append("manual")
177178
cc_binary(
178179
name = raw_binary_name,
179180
**binary_kwargs
@@ -251,6 +252,7 @@ def java_fuzz_test(
251252
"Jazzer-Fuzz-Target-Class: %s" % target_class,
252253
]
253254
binary_kwargs.setdefault("deps", []).append(engine)
255+
binary_kwargs.setdefault("tags", []).append("manual")
254256
native.java_binary(
255257
name = raw_target_name,
256258
srcs = srcs,
@@ -282,6 +284,7 @@ def java_fuzz_test(
282284
"@rules_fuzzing//fuzzing/private:use_oss_fuzz": "@rules_fuzzing//fuzzing/private:oss_fuzz_jazzer_sanitizer_options.sh",
283285
"//conditions:default": "@rules_fuzzing//fuzzing/private:local_jazzer_sanitizer_options.sh",
284286
}),
287+
tags = ["manual"],
285288
target = raw_target_name,
286289
target_deploy_jar = raw_target_name + "_deploy.jar",
287290
)

fuzzing/private/java_utils.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ runfiles_export_envvars
110110
# Determine the path to load libjvm.so from, either relative to the location of
111111
# the java binary or to $JAVA_HOME, if set. On OSS-Fuzz, the path is provided in
112112
# JVM_LD_LIBRARY_PATH.
113-
JAVA_BIN=$(readlink -f "$(which java)")
113+
JAVA_BIN=$(python3 -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' "$(which java)")
114114
JAVA_HOME=${JAVA_HOME:-${JAVA_BIN%/bin/java}}
115115
# The location of libjvm.so relative to the JDK differs between JDK <= 8 and 9+.
116116
JVM_LD_LIBRARY_PATH=${JVM_LD_LIBRARY_PATH:-"$JAVA_HOME/lib/server:$JAVA_HOME/lib/amd64/server"}

fuzzing/replay/replay_main.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
extern "C" {
2424
int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);
25-
int LLVMFuzzerInitialize(int* argc, char*** argv) __attribute__((weak_import));
25+
int LLVMFuzzerInitialize(int* argc, char*** argv) __attribute__((weak));
2626
}
2727

2828
namespace {

0 commit comments

Comments
 (0)