Bug 92890 - Do not merge "identical" compilation flags
Summary: Do not merge "identical" compilation flags
Status: RESOLVED FIXED
Alias: None
Product: pkg-config
Classification: Unclassified
Component: src (show other bugs)
Version: unspecified
Hardware: All All
: medium normal
Assignee: pkg-config
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-10 15:54 UTC by Nadav Har'El
Modified: 2015-11-10 22:26 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Nadav Har'El 2015-11-10 15:54:40 UTC
The pkg-config(1) mentions that for --cflags and --libs, "Flags are "compressed" so that each identical flag appears only once.".

This "compression" sounds harmless but it really isn't. For example, in one real-life ".pc" file we had the following:

Libs: -L/home/sothy/seastar/build/release -Wl,--whole-archive -lseastar -Wl,--no-whole-archive -g -Wl,--no-as-needed   -fvisibility=hidden -pthread  -laio -lboost_program_options -lboost_system -lstdc++ -lm -lboost_unit_test_framework -lboost_thread -lcryptopp -lrt -lxenstore -L/home/sothy/seastar/build/dpdk/lib -Wl,--whole-archive -lrte_pmd_vmxnet3_uio -lrte_pmd_i40e -lrte_pmd_ixgbe -lrte_pmd_e1000 -lrte_pmd_ring -Wl,--no-whole-archive -lrte_hash -lrte_kvargs -lrte_mbuf -lethdev -lrte_eal -lrte_malloc -lrte_mempool -lrte_ring -lrte_cmdline -lrte_cfgfile -lrt -lm -ldl -lhwloc -lnuma -lpciaccess -lxml2 -lz 


Note how the "-Wl,--whole-archive" option (and also "-Wl,--no-whole-archive") appears twice, surrounding two different sets of libraries. Dropping one of the copies of these flags, or reordering them, is absolutely wrong because their exact position matters.

I can easily work around this bug - e.g., by moving libraries around so we have only one whole-archive/no-whole-archive pair, or by changing the multi-word "-Wl,--whole-archive -lseastar -Wl,--no-whole-archive" to a single word "-Wl,--whole-archive,-lseastar,--no-whole-archive". 

However, I'd prefer not to work around this bug - other people might encounter it in other scenarios as well. There are various other cases where repeating the same flag or library again can cause the compilation to change. so why not just fix it? Why is it important that pkg-config "compress" identical flags? Where did this requirement come from?
Comment 1 Nadav Har'El 2015-11-10 16:01:09 UTC
I just noticed in http://lists.freedesktop.org/archives/pkg-config/2013-January/000912.html that maybe this issue has been solved in pkg-config 0.28?
If that is the case, maybe this issue should be closed...


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.