Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boost: fix cross-compile support #105478

Closed
wants to merge 1 commit into from
Closed

Conversation

hlandau
Copy link
Contributor

@hlandau hlandau commented Nov 30, 2020

Motivation for this change

boost fails to cross-compile, for example when targeting mingw. This is a simple fix.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@hlandau
Copy link
Contributor Author

hlandau commented Nov 30, 2020

cc @peti

@veprbl veprbl added the 6.topic: cross-compilation Building packages on a different sort platform than than they will be run on label Dec 3, 2020
$ECHO -n "Building Boost.Build engine with toolset $TOOLSET... "
pwd=`pwd`
- (cd "$my_dir/tools/build/src/engine" && ./build.sh "$TOOLSET") > bootstrap.log 2>&1
+ (cd "$my_dir/tools/build/src/engine" && CXX="$CXX_FOR_BUILD" ./build.sh "$TOOLSET") > bootstrap.log 2>&1
Copy link
Member

@veprbl veprbl Dec 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it not work to properly set the value of toolset instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@hlandau hlandau Dec 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BUILD_CXX is only used if TOOLSET is set to cross-cxx. Moreover doing so just sets CXX to BUILD_CXX. https://github.com/boostorg/build/blob/495b7ee9970787319dad6c70707ee8f4f18363e8/src/engine/build.sh#L429

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And then B2_CXX is set to the value of CXX, so that might be how cross compiling is implemented.

@alyssais
Copy link
Member

alyssais commented Feb 8, 2021

(My force push just adds the Fixes: tag, since this PR fixes #96336)

@@ -114,7 +114,8 @@ stdenv.mkDerivation {
then ./darwin-1.55-no-system-python.patch
else ./darwin-no-system-python.patch)
++ optional (and (versionAtLeast version "1.70") (!versionAtLeast version "1.73")) ./cmake-paths.patch
++ optional (versionAtLeast version "1.73") ./cmake-paths-173.patch;
++ optional (versionAtLeast version "1.73") ./cmake-paths-173.patch
++ optional (stdenv.hostPlatform != stdenv.buildPlatform) ./cross.patch;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch doesn't apply to boost 1.75. After fixing up the patch, I was able to cross-compile to riscv64.

IMO patches should be applied unconditionally whenever possible. If they're conditional on certain architectures or setups, they can break silently after version bumps. In this case, that means a mass rebuild, so we'll want to send this through staging.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you post the correct patch, please?
Or push it here or open a new PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heads up that this probably won't apply to all versions, I only tested this on 1.75.

index ca0b08d58..5d4105ffe 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -225,4 +225,4 @@
   pwd=`pwd`
-  (cd "$my_dir/tools/build/src/engine" && ./build.sh)
+  (cd "$my_dir/tools/build/src/engine" && CXX="$CXX_FOR_BUILD" ./build.sh)
   if [ $? -ne 0 ]; then

@oxalica oxalica mentioned this pull request Feb 25, 2021
10 tasks
@hlandau hlandau deleted the boost-mingw branch March 17, 2021 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: cross-compilation Building packages on a different sort platform than than they will be run on 10.rebuild-darwin: 0 10.rebuild-linux: 0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants