* Jan Engelhardt:

> On Thursday 2026-01-15 13:16, Guillem Jover wrote:
>>
>>As part of that report, my current inclination is to perhaps add a new
>>variable for such direct ld(1) call use, where I'm tentatively naming
>>it LD_LDFLAGS.
>
> LD_LDFLAGS is backwards. The general established pattern...
>
> CPP -> CPPFLAGS
> CPPAS -> CPPASFLAGS
> CCAS -> CCASFLAGS
> CXX -> CXXFLAGS
> OBJC -> OBJCFLAGS
> OBJCXX -> OBJCXXFLAGS
> LD -> LDFLAGS
>
> so if, then do it like so:
>
> CCLD -> CCLDFLAGS
> CXXLD -> CXXLDFLAGS
> FCLD -> FCLDFLAGS
>
>
>>In dpkg we define several build flags defaults per vendor via
>>dpkg-buildflags(1) (<https://manpages.debian.org/dpkg-buildflags>),
>>and increasingly we have been adding options for the linker in LDFLAGS.
>>The problem is that some (few) projects are using that for direct
>>calls to ld(1) without going through the compiler. This is causing
>>build failures now.
>>
>>https://bugs.debian.org/1125323
>>ld: -f may not be used without -shared
>
> -fcf-protection is not a linker flag and does not belong into LDFLAGS.

LDFLAGS are linker flags for the compiler driver (with -Wl, escaping
etc.).  LDFLAGS must contain -fcf-protection when using LTO.

See this example from the make manual:

|           myprog: myprog.o file1.o file2.o
|                  $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)

It's even documented as such:

| 'LDFLAGS'
|      Extra flags to give to compilers when they are supposed to invoke
|      the linker, 'ld', such as '-L'.  Libraries ('-lfoo') should be
|      added to the 'LDLIBS' variable instead.

ASFLAGS has the ambiguity because the default make rules use it with
both AS (for .s) and CC and (.S), which makes ASFLAGS rather useless.

LDFLAGS doesn't, it's always for the compiler driver (unless the build
system is really buggy).

Thanks,
Florian


Reply via email to