bazel-contrib / rules_foreign_cc

Build rules for interfacing with "foreign" (non-Bazel) build systems (CMake, configure-make, GNU Make, boost, ninja, Meson)
https://bazel-contrib.github.io/rules_foreign_cc
Apache License 2.0
680 stars 249 forks source link

configure_make: support autotools cross-compilation #1247

Closed novas0x2a closed 3 months ago

novas0x2a commented 3 months ago

This teaches the autotools-based configure script to pass --host when cross-compilation is detected. This fixes at least part of #1082. This functionality is off by default (because configure_make can be used for non-autotools builds) and can be enabled by passing configure_xcompile to configure_make.

This functionality is also extended to the built_tools that use autoconf (pkg-config and make).

It also does a bit of generalization to make it easier to support more platforms in the future, and adds s390x to the detected arches.

novas0x2a commented 3 months ago

@jsharpe looks like this probably works now! The only failing builds are the ones that seem to be failing on main, too. (I've tested this in our internal setup on linux, and @matt-sm should be testing on darwin).

novas0x2a commented 3 months ago

LGTM - will wait on @matt-sm to test on darwin though as I had some questions about whether the macos triplet names were correct..

Mentioned in the review comments above, but I ended up running this in our darwin CI and it worked.

novas0x2a commented 3 months ago

I pushed a new version with a few fixes, including fixing two brown-paper-bag fixes (I had two bugs that cancelled each other out, that I've now fixed)

allsey87 commented 3 months ago

@novas0x2a could you add a brief example here of how to use xcompile_options with configure_make?

I might make another PR to add the wasm32 CPU and emscripten OS to the supported platforms.

novas0x2a commented 3 months ago

@allsey87:

@novas0x2a could you add a brief example here of how to use xcompile_options with configure_make?

Looks like the docs generation hasn't run yet, but, the version that landed just has a bool, configure_xcompile; defaults to false, if you set it to true it will pass --host and --build (as detected by bazel) to configure. Note that this is causing rfcc to detect the cross-compilation, but only if bazel is already operating in cross-compile mode.

I might make another PR to add the wasm32 CPU and emscripten OS to the supported platforms.

It'd need to match the upstream tokens:

allsey87 commented 3 months ago

I might make another PR to add the wasm32 CPU and emscripten OS to the supported platforms.

It'd need to match the upstream tokens:

They are there:

https://github.com/bazelbuild/platforms/blob/main/os/BUILD#L110 https://github.com/bazelbuild/platforms/blob/main/cpu/BUILD#L168