Skip to content

fix(ninja): compile shared libraries with PIC - #131

Open
Abd-ullah2001 wants to merge 1 commit into
embeddedos-org:masterfrom
Abd-ullah2001:Abdullah-assessment-branch
Open

fix(ninja): compile shared libraries with PIC#131
Abd-ullah2001 wants to merge 1 commit into
embeddedos-org:masterfrom
Abd-ullah2001:Abdullah-assessment-branch

Conversation

@Abd-ullah2001

Copy link
Copy Markdown

Summary

  • Default shared-library compile commands to -fPIC.
  • Preserve an explicit PIC policy while ensuring a later PIE flag cannot
    replace PIC for a shared-library target.
  • Cover both the Ninja manifest and compilation database output with regression
    tests.

Why

The Ninja backend already links shared_library targets with the platform's
shared-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 skipped
  • python -m pytest tests/unit/test_ninja_backend.py -q --tb=short — 16 passed
  • ruff check ebuild/build/ninja_backend.py tests/ebuild/test_ninja_backend.py — passed
  • Changed-file mypy check — no issues in 2 source files
  • python -m build — sdist and wheel built successfully

The full suite currently finishes with 9 failures, 681 passes, and 1 skip. All
nine failures reproduce on upstream master and come from the existing missing
PackageRecipe.to_dict() method in index synchronization; that separate issue
is being addressed in #119. Full-repository Ruff also reports four existing,
unrelated findings being addressed in #122.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant