Regression 31754d4f: gcc -R: command-line option not found #341

Closed
opened 2026-01-29 20:42:15 +00:00 by claunia · 10 comments
Owner

Originally created by @jengelh on GitHub (Sep 1, 2020).

Please have 31754d4f reverted. One cannot build programs with brotli & pkg-config anymore, for reasons of:

gcc: error: unrecognized command-line option ‘-R’

None of the 350-or-so .pc files in my system have any rpath specifiers, and I will make the argument that it is wrong to do so in brotli.pc, especially considering the "cross-compilation" argument made in the commit message of 31754d4f.
While the library may be present in /home/me/aarch64-linux-gnu/sys-root/lib, the rpath will have no effect if and when the system inside sys-root/ is being copied to an SD card where the lib directory just /lib.

Originally created by @jengelh on GitHub (Sep 1, 2020). Please have 31754d4f reverted. One cannot build programs with brotli & pkg-config anymore, for reasons of: gcc: error: unrecognized command-line option ‘-R’ None of the 350-or-so .pc files in my system have any rpath specifiers, and I will make the argument that it is wrong to do so in brotli.pc, _especially_ considering the "cross-compilation" argument made in the commit message of 31754d4f. While the library may be present in /home/me/aarch64-linux-gnu/sys-root/lib, the rpath will have no effect if and when the system inside sys-root/ is being copied to an SD card where the lib directory just /lib.
Author
Owner

@jengelh commented on GitHub (Sep 1, 2020):

» touch x.c
» gcc x.c `pkg-config libbrotlidec --libs`
gcc: error: unrecognized command-line option ‘-R’
@jengelh commented on GitHub (Sep 1, 2020): ``` » touch x.c » gcc x.c `pkg-config libbrotlidec --libs` gcc: error: unrecognized command-line option ‘-R’ ```
Author
Owner

@eustas commented on GitHub (Sep 2, 2020):

Does replacing -R with -Wl,-rpath improve situation?

@eustas commented on GitHub (Sep 2, 2020): Does replacing `-R` with `-Wl,-rpath` improve situation?
Author
Owner

@jengelh commented on GitHub (Sep 2, 2020):

gcc would succeed, but then you still have the problem that you are forcing down an rpath entry into everything that uses brotli.pc, even transitively (i.e. when there is a mylib.pc using Requires: brotli and a call to gcc myprog.c $(pkg-config mylib --libs) which otherwise does not care about brotli).

@jengelh commented on GitHub (Sep 2, 2020): gcc would succeed, but then you still have the problem that you are forcing down an rpath entry into everything that uses brotli.pc, even transitively (i.e. when there is a `mylib.pc` using `Requires: brotli` and a call to `gcc myprog.c $(pkg-config mylib --libs)` which otherwise does not care about brotli).
Author
Owner

@eustas commented on GitHub (Sep 2, 2020):

Got it. Thanks.

@eustas commented on GitHub (Sep 2, 2020): Got it. Thanks.
Author
Owner

@eustas commented on GitHub (Sep 2, 2020):

Reverted with #838

@eustas commented on GitHub (Sep 2, 2020): Reverted with #838
Author
Owner

@nigoroll commented on GitHub (Sep 26, 2020):

None of the 350-or-so .pc files in my system have any rpath specifiers

I understand that the issue had to be resolved by reverting the RPATH config, but the reason for above will most likely be that they all refer to libraries installed in the default path.

@nigoroll commented on GitHub (Sep 26, 2020): > None of the 350-or-so .pc files in my system have any rpath specifiers I understand that the issue had to be resolved by reverting the RPATH config, but the reason for above will most likely be that they all refer to libraries installed in the default path.
Author
Owner

@jengelh commented on GitHub (Oct 2, 2020):

will most likely be that they all refer to libraries installed in the default path.

Negative. pkg-config is used (here) as a build-time utility. It need only satisfy the linker, and -L is all that is needed.
pkg-config does not participate in runtime resolution of paths, that instead is a property that ought to be configured elsewhere, i.e. ld.so.conf or other mechanisms.

@jengelh commented on GitHub (Oct 2, 2020): >will most likely be that they all refer to libraries installed in the default path. Negative. pkg-config is used (here) as a build-time utility. It need only satisfy the linker, and `-L` is all that is needed. pkg-config does not participate in runtime resolution of paths, that instead is a property that ought to be configured elsewhere, i.e. ld.so.conf or other mechanisms.
Author
Owner

@nigoroll commented on GitHub (Oct 2, 2020):

then that is the default path

@nigoroll commented on GitHub (Oct 2, 2020): then that _is_ the default path
Author
Owner

@jengelh commented on GitHub (Oct 12, 2020):

then that is the default path

-L controls the ld linker (/usr/bin/ld or the like), -R/-rpath controls the runtime linker (ld.so or whatever).
The build system need not be the same as the target system, injecting -R is an error. Particularly when, for example,

» cat ./scripts/libbrotlienc.pc
prefix=/usr/x86_64-w64-mingw32/sys-root/mingw
exec_prefix=/usr/x86_64-w64-mingw32/sys-root/mingw
libdir=/usr/x86_64-w64-mingw32/sys-root/mingw/lib
includedir=/usr/x86_64-w64-mingw32/sys-root/mingw/include

Name: libbrotlienc
URL: https://github.com/google/brotli
Description: Brotli encoder library
Version: 1.0.9
Libs: -L${libdir} -R${libdir} -lbrotlienc
Requires.private: libbrotlicommon >= 1.0.2
Cflags: -I${includedir}

the -R path is not going to exist in the target environment.

@jengelh commented on GitHub (Oct 12, 2020): > then that _is_ the default path -L controls the ld linker (/usr/bin/ld or the like), -R/-rpath controls the runtime linker (ld.so or whatever). The build system need not be the same as the target system, injecting -R is an error. Particularly when, for example, ``` » cat ./scripts/libbrotlienc.pc prefix=/usr/x86_64-w64-mingw32/sys-root/mingw exec_prefix=/usr/x86_64-w64-mingw32/sys-root/mingw libdir=/usr/x86_64-w64-mingw32/sys-root/mingw/lib includedir=/usr/x86_64-w64-mingw32/sys-root/mingw/include Name: libbrotlienc URL: https://github.com/google/brotli Description: Brotli encoder library Version: 1.0.9 Libs: -L${libdir} -R${libdir} -lbrotlienc Requires.private: libbrotlicommon >= 1.0.2 Cflags: -I${includedir} ``` the -R path is not going to exist in the target environment.
Author
Owner

@nigoroll commented on GitHub (Oct 12, 2020):

@jengelh I am aware that this topic is controversial, but cross compiling brings even more challenges. In your example the .pc file should contain -R as seen by the target system, and, yes, we have not considered that in 31754d4ffc

The trouble is really that, with non-default install paths (that is, paths not configured via ldconfig, the evil LD_LIBERARY_PATH etc), not having -R in the pkg-config Libs will require adding that -R to the consuming package's build, which to avoid is exactly the goal of pkg-config.

@nigoroll commented on GitHub (Oct 12, 2020): @jengelh I am aware that [this topic is controversial](https://wiki.debian.org/RpathIssue), but [cross compiling brings even more challenges](https://www.freedesktop.org/wiki/Software/pkg-config/CrossCompileProposal/). In your example the `.pc` file should contain `-R` as seen by the target system, and, yes, we have not considered that in 31754d4ffce14153b5c2addf7a11019ec23f51c1 The trouble is really that, with non-default install paths (that is, paths _not_ configured via `ldconfig`, the evil `LD_LIBERARY_PATH` etc), not having `-R` in the pkg-config `Libs` will require adding that `-R` to the consuming package's build, which to avoid is exactly the goal of pkg-config.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#341