fix(ninja): compile shared libraries with PIC - #131
Open
Abd-ullah2001 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
-fPIC.replace PIC for a shared-library target.
tests.
Why
The Ninja backend already links
shared_librarytargets with the platform'sshared-library rule, but their source objects could be compiled without
position-independent code. On ELF and common cross toolchains, that can make
the final link fail with relocation errors asking for the objects to be rebuilt
with
-fPIC.PIC and PIE are also not interchangeable here: PIE output is intended for
executables. The resolver now considers flag order and makes sure the last
effective policy for a shared-library compile is PIC, unless the project has
explicitly selected a PIC policy itself.
Validation
python -m pytest tests/ebuild/test_ninja_backend.py -q --tb=short— 13 passed, 1 skippedpython -m pytest tests/unit/test_ninja_backend.py -q --tb=short— 16 passedruff check ebuild/build/ninja_backend.py tests/ebuild/test_ninja_backend.py— passedmypycheck — no issues in 2 source filespython -m build— sdist and wheel built successfullyThe full suite currently finishes with 9 failures, 681 passes, and 1 skip. All
nine failures reproduce on upstream
masterand come from the existing missingPackageRecipe.to_dict()method in index synchronization; that separate issueis being addressed in #119. Full-repository Ruff also reports four existing,
unrelated findings being addressed in #122.