| b9844707 | 30-Jun-2020 |
Bruce Richardson <[email protected]> |
build/pkg-config: prevent overlinking
Add the --as-needed linker flag to the DPDK library list in the pkg-config file so as to prevent overlinking. Without this flag, when linking statically using f
build/pkg-config: prevent overlinking
Add the --as-needed linker flag to the DPDK library list in the pkg-config file so as to prevent overlinking. Without this flag, when linking statically using flags from $(pkg-config --static --libs libdpdk), all DPDK drivers and libs were statically linked in, but the binary was also requiring all the shared versions be present to run.
The real root-cause of this issue is that the DPDK libraries need to be duplicated in the linker command when doing static linking, due to the behaviour of pkg-config, but since that behaviour cannot be easily changed, this is a simple workaround to avoid problems.
Signed-off-by: Bruce Richardson <[email protected]> Acked-by: Luca Boccassi <[email protected]> Acked-by: Sunil Pai G <[email protected]> Signed-off-by: Thomas Monjalon <[email protected]>
show more ...
|
| f9c0b1f4 | 30-Jun-2020 |
Bruce Richardson <[email protected]> |
build/pkg-config: output drivers first for static build
When calling pkg-config --static --libs, pkg-config will always output the regular libs first, and then the extra libs from Libs.private field
build/pkg-config: output drivers first for static build
When calling pkg-config --static --libs, pkg-config will always output the regular libs first, and then the extra libs from Libs.private field, since the assumption is that those are additional dependencies for building statically that the .a files depend upon.
However, for DPDK, we only link the driver files for static builds, and those need to come *before* the regular libraries. To get this result, we need two pkgconfig files for DPDK, one for the shared libs, and a second for the static libs and drivers, which depends upon the first. Using a dependency means that the shared libs are printed only after the Libs.private field rather than before.
Without this patch, the linking works in DPDK because in all cases we specify the libraries after the drivers in the Libs.private line, ensuring that the references to the libs from the drivers can be resolved. The current output is therefore of the form, "(shared)libs, drivers, (static)libs", while after this patch the output is, "drivers, (static)libs, (shared)libs". The former case will not work if we use the --whole-archive flag on the static libs as it will lead to duplicate definitions due to some references having been previously resolved from the shared libraries. By ensuring the shared libraries come last in the link link, this issue does not occur, as duplicate references when linking the shared libs will be ignored.
Signed-off-by: Bruce Richardson <[email protected]> Acked-by: Luca Boccassi <[email protected]> Acked-by: Sunil Pai G <[email protected]> Signed-off-by: Thomas Monjalon <[email protected]>
show more ...
|