diff mbox series

[uci,1/2] fuzz: Compile using libstd++

Message ID 20230308231810.2143384-1-hauke@hauke-m.de
State Under Review
Delegated to: Hauke Mehrtens
Headers show
Series [uci,1/2] fuzz: Compile using libstd++ | expand

Commit Message

Hauke Mehrtens March 8, 2023, 11:18 p.m. UTC
It looks like libfuzzer is compiled using libstd++ on Debian Bookworm
and not libc++. Using libc++ causes linking errors, use libstd++
instead.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 tests/fuzz/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Petr Štetiar March 11, 2023, 9:01 a.m. UTC | #1
Hauke Mehrtens <hauke@hauke-m.de> [2023-03-09 00:18:09]:

Hi,

> It looks like libfuzzer is compiled using libstd++ on Debian Bookworm
> and not libc++. Using libc++ causes linking errors, use libstd++
> instead.

so maybe this should be detected and decided at runtime? Otherwise this seems
to just support Bookworm from now and thus fail to compile elsewhere?

Cheers,

Petr
Hauke Mehrtens March 12, 2023, 9:52 p.m. UTC | #2
On 3/11/23 10:01, Petr Štetiar wrote:
> Hauke Mehrtens <hauke@hauke-m.de> [2023-03-09 00:18:09]:
> 
> Hi,
> 
>> It looks like libfuzzer is compiled using libstd++ on Debian Bookworm
>> and not libc++. Using libc++ causes linking errors, use libstd++
>> instead.
> 
> so maybe this should be detected and decided at runtime? Otherwise this seems
> to just support Bookworm from now and thus fail to compile elsewhere?
> 
> Cheers,
> 
> Petr

Hi Petr,

I tried this in a Debian bullseye container too and there it also works 
fine with libstd++.

What libfuzzer did you use in your container in gitlab?

An automatic detection would be nice, but I have no idea how to do it.

Hauke
Petr Štetiar March 15, 2023, 2:11 p.m. UTC | #3
Hauke Mehrtens <hauke@hauke-m.de> [2023-03-12 22:52:50]:

Hi,

> What libfuzzer did you use in your container in gitlab?

I was using clang builds from apt.llvm.org[1].

> An automatic detection would be nice, but I have no idea how to do it.

I found only https://gitlab.kitware.com/cmake/cmake/-/issues/18275 which has
some ideas and further pointers, but unfortunately no copy&paste-able
solution.

Anyway, I wouldn't waste more time on this, simply push the patch as proposed
and move on, we're all going to use that same tool container in the end, so it
should always provide some common working starting point.

1. https://gitlab.com/ynezz/openwrt-ci/-/blob/master/docker/Dockerfile#L9

Cheers,

Petr
diff mbox series

Patch

diff --git a/tests/fuzz/CMakeLists.txt b/tests/fuzz/CMakeLists.txt
index 1533c46..f1b4a0d 100644
--- a/tests/fuzz/CMakeLists.txt
+++ b/tests/fuzz/CMakeLists.txt
@@ -4,7 +4,7 @@  MACRO(ADD_FUZZER_TEST name)
   ADD_EXECUTABLE(${name} ${name}.c)
   TARGET_COMPILE_OPTIONS(${name} PRIVATE -g -O1 -fno-omit-frame-pointer -fsanitize=fuzzer,address,leak,undefined)
   TARGET_INCLUDE_DIRECTORIES(${name} PRIVATE ${PROJECT_SOURCE_DIR})
-  TARGET_LINK_OPTIONS(${name} PRIVATE -stdlib=libc++ -fsanitize=fuzzer,address,leak,undefined)
+  TARGET_LINK_OPTIONS(${name} PRIVATE -fsanitize=fuzzer,address,leak,undefined)
   TARGET_LINK_LIBRARIES(${name} uci)
   ADD_TEST(
     NAME ${name}