Bug 97337 - pkg-config: Does not support sysroot when using -isystem or -idirafter flags (affects libbsd-overlay)
Summary: pkg-config: Does not support sysroot when using -isystem or -idirafter flags ...
Status: RESOLVED FIXED
Alias: None
Product: pkg-config
Classification: Unclassified
Component: src (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Dan Nicholson
QA Contact:
URL:
Whiteboard:
Keywords:
: 99516 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-08-13 22:16 UTC by Vincent Bernat
Modified: 2017-06-19 02:59 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments
check: Add more flags to the special-flags test (1.82 KB, patch)
2016-09-24 04:09 UTC, Dan Nicholson
Details | Splinter Review
check: Include special-flags in sysroot test (1.08 KB, patch)
2016-09-24 04:10 UTC, Dan Nicholson
Details | Splinter Review
Respect sysroot for -isystem and -idirafter (4.60 KB, patch)
2016-09-24 04:10 UTC, Dan Nicholson
Details | Splinter Review

Description Vincent Bernat 2016-08-13 22:16:06 UTC
Hey!

When using libbsd-overlay with buildroot, we get this error:

http://autobuild.buildroot.net/results/c8a/c8a6001f437701ecc75f6c9252935645bda8a8c8/lldpd-0.9.4/config.log

(search for "isystem", scroll down a bit)

It seems the problem is that pkg-config will prefix all paths with the sysroot but doesn't do that for -isystem. Therefore, the host headers are used instead of the target ones.

See also:
 http://lists.busybox.net/pipermail/buildroot/2016-August/169758.html

Dunno how to fix that exactly.
Comment 1 Guillem Jover 2016-09-22 20:18:24 UTC
Hi¡

I think this needs to be fixed in pkg-config itself. Because it already understands -isystem and -idirafter, but it does not prefix them with the sysroot path when specified.

As a "temporary" workarounds you could switch to use pkgconf which seems to have already fixed this issue last month. Because the only workarounds that occur to me when using pkg-config for now are to fix its output in configure.ac scripts and similar which might bee too invasive. Or perhaps hardcode the sysroot path in the libbsd-overlay.pc file? (ugh)
Comment 2 Dan Nicholson 2016-09-23 03:41:45 UTC
Hmm, hadn't thought of that case. pkg-config prepends the sysroot for -I or -L flags. I think it could be extended to cover -isystem pretty easily.
Comment 3 Dan Nicholson 2016-09-24 04:09:55 UTC
Created attachment 126755 [details] [review]
check: Add more flags to the special-flags test

Make sure that all the flag types are covered so that the ordering
between them is being tested.
Comment 4 Dan Nicholson 2016-09-24 04:10:02 UTC
Created attachment 126756 [details] [review]
check: Include special-flags in sysroot test

Make sure that the sysroot behavior works right when we have non-I/L
flags to consider.
Comment 5 Dan Nicholson 2016-09-24 04:10:14 UTC
Created attachment 126757 [details] [review]
Respect sysroot for -isystem and -idirafter

Treat -isystem and -idirafter as -I Cflags since they control the
compiler search path. Adjust the sysroot handling so that the arguments
to these options have the sysroot prefixed. However, leave them out of the
system Cflags handling since these directives are explicitly trying to
adjust the compiler's system header search behavior.

The special-flags test case output needs adjustment since all the flags
are now considered -I flags and come out in the order specified in the
pc file.
Comment 6 Dan Nicholson 2016-09-24 04:13:10 UTC
This fixes it in my testing. The 3rd patch is the important one. The others are just for prepping the test suite. Can you test it out?
Comment 7 Dan Nicholson 2017-03-20 12:14:56 UTC
I went ahead and pushed the patches since I think they do the right
thing. Please reopen if this doesn't work for you.

Attachment 126755 [details] pushed as a737256 - check: Add more flags to the special-flags test
Attachment 126756 [details] pushed as 7707d2f - check: Include special-flags in sysroot test
Attachment 126757 [details] pushed as d5d8074 - Respect sysroot for -isystem and -idirafter
Comment 8 Guillem Jover 2017-06-19 02:59:56 UTC
*** Bug 99516 has been marked as a duplicate of this bug. ***


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.