Skip to content

Commit 8fcfdda

Browse files
committed
curl: silence false positives with linux cross-build from mac [ci skip]
This has been discussed earlier with the curl team and concluded these are false positives. Silencing them in code is not practical, and it only affects a narrow build case. Therefore this patch silences it within the narrow build case by making this warning a non-error. This makes it possible to enable `werror` by default. ``` curl/lib/vquic/curl_ngtcp2.c: In function 'cf_ngtcp2_send': curl/lib/vquic/curl_ngtcp2.c:1511:38: error: potential null pointer dereference [-Werror=null-dereference] 1511 | nva[i].value = (unsigned char *)e->value; | ~^~~~~~~ curl/lib/vquic/curl_ngtcp2.c:1510:23: error: potential null pointer dereference [-Werror=null-dereference] 1510 | nva[i].namelen = e->namelen; | ~^~~~~~~~~ curl/lib/vquic/curl_ngtcp2.c:1509:37: error: potential null pointer dereference [-Werror=null-dereference] 1509 | nva[i].name = (unsigned char *)e->name; | ~^~~~~~ curl/lib/vquic/curl_ngtcp2.c:1512:24: error: potential null pointer dereference [-Werror=null-dereference] 1512 | nva[i].valuelen = e->valuelen; | ~^~~~~~~~~~ ``` Ref: https://github.com/curl/curl-for-win/actions/runs/16525969694/job/46739239259#step:3:4981 (same for curl_quiche.c, curl_osslq.c, curl_msh3.c) Ref: curl/curl#18025 (not merged) Ref: curl/curl#12079 (not merged) Ref: curl/curl#12076
1 parent b44ac7c commit 8fcfdda

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

curl.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ _VER="$1"
3131
# Build
3232

3333
options=''
34+
CFLAGS=''
3435
CPPFLAGS=''
3536

3637
LIBS=''
@@ -321,6 +322,16 @@ _VER="$1"
321322
options+=' -DCMAKE_UNITY_BUILD=ON'
322323
if [[ "${_CONFIG}" =~ (dev|unitybatch) ]]; then
323324
options+=' -DCMAKE_UNITY_BUILD_BATCH_SIZE=30'
325+
else
326+
# Prevent false positive compiler warnings breaking the build when
327+
# building for linux on mac in single-batch unity mode.
328+
# Seen with gcc 9.2.0 via filosottile/musl-cross/musl-cross
329+
if [ "${_HOST}" = 'mac' ] && \
330+
[ "${_OS}" = 'linux' ] && \
331+
[ "${_CC}" = 'gcc' ] && \
332+
[ "${_CRT}" = 'musl' ]; then
333+
CFLAGS+=' -Wno-error=null-dereference'
334+
fi
324335
fi
325336
fi
326337

@@ -375,7 +386,7 @@ _VER="$1"
375386
-DBUILD_STATIC_LIBS=ON \
376387
-DCURL_HIDDEN_SYMBOLS=ON \
377388
-DCMAKE_RC_FLAGS="${_RCFLAGS_GLOBAL}" \
378-
-DCMAKE_C_FLAGS="${_CFLAGS_GLOBAL_CMAKE} ${_CFLAGS_GLOBAL} ${_CPPFLAGS_GLOBAL} ${CPPFLAGS} ${_LDFLAGS_GLOBAL}" \
389+
-DCMAKE_C_FLAGS="${_CFLAGS_GLOBAL_CMAKE} ${_CFLAGS_GLOBAL} ${_CPPFLAGS_GLOBAL} ${CFLAGS} ${CPPFLAGS} ${_LDFLAGS_GLOBAL}" \
379390
-DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS} ${LDFLAGS_BIN} ${LIBS}" \
380391
-DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS} ${LDFLAGS_LIB} ${LIBS}" \
381392
|| { cat "${_BLDDIR}"/CMakeFiles/CMake*.yaml; false; }

0 commit comments

Comments
 (0)