macOS, clang, pkgsrc: -Werror part 2

1 view
Skip to first unread message

Greg Troxel

unread,
Sep 12, 2025, 8:39:15 PMSep 12
to bup-...@googlegroups.com
I can make a proper commit, but

- pkgsrc adds -L for the pkgsrc compiler wrappers lib directory, for
visibility control
- bup passes -Werror in try_c_code() in configure
- clang warns if there is a -L which is unused. That's a bug, because
-L means "if you are looking for a library, look here too" and it's
not wrong to include -L on link lines that don't have a -l.


Without this some mincore tests fail.

I mostly recall fixing a different instance of this.

This diff is against 0.33.9.



$NetBSD: patch-config_configure,v 1.4 2025/09/13 00:33:37 gdt Exp $

Disable -Werror on test builds, to avoid running afoul of clang
complaining that a -L flag was "unused".

Sent to bup via email. Arguably this is a clang bug, but I have no
reason to expect it to be fixed there.

--- config/configure.orig 2025-08-30 18:10:07.000000000 +0000
+++ config/configure
@@ -29,7 +29,7 @@ bup_try_c_code()
esac
tmpdir="$(mktemp -d "bup-try-c-compile-XXXXXXX")" || exit $?
echo "$code" > "$tmpdir/test.c" || exit $?
- $AC_CC -Wall -Werror $cflags -c -o "$tmpdir/test" "$tmpdir/test.c"
+ $AC_CC -Wall $cflags -c -o "$tmpdir/test" "$tmpdir/test.c"
rc=$?
rm -r "$tmpdir" || exit $?
return $rc

Johannes Berg

unread,
Sep 15, 2025, 2:35:12 AMSep 15
to Greg Troxel, bup-...@googlegroups.com
On Fri, 2025-09-12 at 20:39 -0400, Greg Troxel wrote:
> I can make a proper commit, but
>
> - pkgsrc adds -L for the pkgsrc compiler wrappers lib directory, for
> visibility control
> - bup passes -Werror in try_c_code() in configure
> - clang warns if there is a -L which is unused. That's a bug, because
> -L means "if you are looking for a library, look here too" and it's
> not wrong to include -L on link lines that don't have a -l.

I'd argue it's not a clang bug (although I do sometimes wish clang was
less strict about this kind of issue), because

> +++ config/configure
> @@ -29,7 +29,7 @@ bup_try_c_code()
> esac
> tmpdir="$(mktemp -d "bup-try-c-compile-XXXXXXX")" || exit $?
> echo "$code" > "$tmpdir/test.c" || exit $?
> - $AC_CC -Wall -Werror $cflags -c -o "$tmpdir/test" "$tmpdir/test.c"
> + $AC_CC -Wall $cflags -c -o "$tmpdir/test" "$tmpdir/test.c"

That command line really is, due to the "-c", a pure compilation
(technically "preprocess, compile, and assemble steps") command without
any linking.

johannes

Greg Troxel

unread,
Sep 15, 2025, 7:16:17 AMSep 15
to Johannes Berg, bup-...@googlegroups.com
Johannes Berg <joha...@sipsolutions.net> writes:

> On Fri, 2025-09-12 at 20:39 -0400, Greg Troxel wrote:
>> I can make a proper commit, but
>>
>> - pkgsrc adds -L for the pkgsrc compiler wrappers lib directory, for
>> visibility control
>> - bup passes -Werror in try_c_code() in configure
>> - clang warns if there is a -L which is unused. That's a bug, because
>> -L means "if you are looking for a library, look here too" and it's
>> not wrong to include -L on link lines that don't have a -l.
>
> I'd argue it's not a clang bug (although I do sometimes wish clang was
> less strict about this kind of issue), because

It said "unused", vs "-L was passed to a -c call", but I see your point.

>> +++ config/configure
>> @@ -29,7 +29,7 @@ bup_try_c_code()
>> esac
>> tmpdir="$(mktemp -d "bup-try-c-compile-XXXXXXX")" || exit $?
>> echo "$code" > "$tmpdir/test.c" || exit $?
>> - $AC_CC -Wall -Werror $cflags -c -o "$tmpdir/test" "$tmpdir/test.c"
>> + $AC_CC -Wall $cflags -c -o "$tmpdir/test" "$tmpdir/test.c"
>
> That command line really is, due to the "-c", a pure compilation
> (technically "preprocess, compile, and assemble steps") command without
> any linking.

Hmm, I guess it is, but it's bizarre to have -o to test (vs test.o).
Perhaps -L from pkgsrc was triggered by that.

Johannes Berg

unread,
Sep 15, 2025, 7:19:48 AMSep 15
to Greg Troxel, bup-...@googlegroups.com
On Mon, 2025-09-15 at 07:16 -0400, Greg Troxel wrote:
> Johannes Berg <joha...@sipsolutions.net> writes:
>
> > On Fri, 2025-09-12 at 20:39 -0400, Greg Troxel wrote:
> > > I can make a proper commit, but
> > >
> > > - pkgsrc adds -L for the pkgsrc compiler wrappers lib directory, for
> > > visibility control
> > > - bup passes -Werror in try_c_code() in configure
> > > - clang warns if there is a -L which is unused. That's a bug, because
> > > -L means "if you are looking for a library, look here too" and it's
> > > not wrong to include -L on link lines that don't have a -l.
> >
> > I'd argue it's not a clang bug (although I do sometimes wish clang was
> > less strict about this kind of issue), because
>
> It said "unused", vs "-L was passed to a -c call", but I see your point.

Right, since there's no link stage it's (necessarily!) unused.

> > > +++ config/configure
> > > @@ -29,7 +29,7 @@ bup_try_c_code()
> > > esac
> > > tmpdir="$(mktemp -d "bup-try-c-compile-XXXXXXX")" || exit $?
> > > echo "$code" > "$tmpdir/test.c" || exit $?
> > > - $AC_CC -Wall -Werror $cflags -c -o "$tmpdir/test" "$tmpdir/test.c"
> > > + $AC_CC -Wall $cflags -c -o "$tmpdir/test" "$tmpdir/test.c"
> >
> > That command line really is, due to the "-c", a pure compilation
> > (technically "preprocess, compile, and assemble steps") command without
> > any linking.
>
> Hmm, I guess it is, but it's bizarre to have -o to test (vs test.o).

Huh, I didn't even notice that, but yeah.

> Perhaps -L from pkgsrc was triggered by that.

No idea. I've been fighting nixos clang wrappers, so I'm a bit allergic
to wrappers right now ;-)

johannes

Greg Troxel

unread,
Sep 15, 2025, 7:23:59 AMSep 15
to Johannes Berg, bup-...@googlegroups.com
Johannes Berg <joha...@sipsolutions.net> writes:

>> It said "unused", vs "-L was passed to a -c call", but I see your point.
>
> Right, since there's no link stage it's (necessarily!) unused.

Technically you are right, but saying it's unused when it's not obvious
what the call was is really not helpful.

>> Hmm, I guess it is, but it's bizarre to have -o to test (vs test.o).
>
> Huh, I didn't even notice that, but yeah.

I guess we should fix that too.

Rob Browning

unread,
Sep 15, 2025, 11:01:51 PMSep 15
to Greg Troxel, Johannes Berg, bup-...@googlegroups.com
Greg Troxel <g...@lexort.com> writes:

> I guess we should fix that too.

I don't know that it's right enough yet, and it still uses -Werror, but
that's all changed notably in main.

--
Rob Browning
rlb @defaultvalue.org and @debian.org
GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A
GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4
Reply all
Reply to author
Forward
0 new messages