Skip to content

[feature] Autodetect <target-os> from compiler triplet - #609

Open
uilianries wants to merge 6 commits into
bfgroup:mainfrom
uilianries:feature/target-os-autodetect
Open

[feature] Autodetect <target-os> from compiler triplet#609
uilianries wants to merge 6 commits into
bfgroup:mainfrom
uilianries:feature/target-os-autodetect

Conversation

@uilianries

Copy link
Copy Markdown
Contributor

Proposed changes

Greetings! 👋

While working on the Conan Center boost recipe, cross-compiling required the recipe to compute and pass target-os= explicitly for every target (expected as explicitly documented at https://www.bfgroup.xyz/b2/manual/release/index.html#b2.tasks.crosscompile), even though the compiler itself already knows what it's targeting.

The gcc.jam already runs -dumpmachine, and maps the resulting triple to a <target-os> value, and registers it as a default via toolset.add-defaults.

On the other hand, clang-linux.jam and clang-darwin.jam have no equivalent, when cross-building with clang, it falls back to the host OS unless target-os= is passed.

This PR updates the clang.set-target-os-default to follow the same auto-detect rule as used in gcc.jam. I also extended gcc.jam, so both clang and gcc match in terms of OS cases.

I also added a new test to validate it, by mocking the triplet and asking b2 to deduce the target-os.

Types of changes

What types of changes does your code introduce?

Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Documentation content changes
  • Other (please describe):

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I searched the discussions
  • I searched the closed and open issues
  • I read the contribution guidelines
  • I added myself to the copyright attributions for significant changes
  • I checked that tests pass locally with my changes
  • I added tests that prove my fix is effective or that my feature works
  • I added necessary documentation (if appropriate)

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
@uilianries

Copy link
Copy Markdown
Contributor Author

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