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

[bug] When cross building AutotoolsToolchain does not pass --build option if there is any configure argument with "build" in its name #12642

Closed
ovostrikov opened this issue Dec 1, 2022 · 2 comments · Fixed by #12884
Assignees
Milestone

Comments

@ovostrikov
Copy link

ovostrikov commented Dec 1, 2022

Environment Details

  • Operating System+version: WSL Ubuntu 20.04
  • Compiler+version: clang 15
  • Conan version: 1.54
  • Python version: 3.8

Steps to reproduce

conan new at/1.0.0 -t -m autotools_lib

Edit the conanfile generate method to add

    def generate(self):
        at_toolchain = AutotoolsToolchain(self)
        at_toolchain.configure_args.append(f"--with-cross-build=some_path")
        at_toolchain.generate()

Create cross-build-profile file

include(default)
[settings]
os=Emscripten
os_build=Linux
arch=wasm
arch_build=x86_64

Run

conan create . --profile=cross-build-profile --profile:build=default -tf=None  > log.txt
grep '\--build' log.txt

Expected result

The '--build=x86_64-linux-gnu' option should be present:

> '--disable-shared' '--enable-static' '--prefix=/' '--bindir=${prefix}/bin' '--sbindir=${prefix}/bin' '--libdir=${prefix}/lib' '--includedir=${prefix}/include' '--oldincludedir=${prefix}/include' '--with-cross-build=some_path' '--host=wasm32-local-emscripten' '--build=x86_64-linux-gnu'

Actual result

The '--build=x86_64-linux-gnu' option is missing

'--disable-shared' '--enable-static' '--prefix=/' '--bindir=${prefix}/bin' '--sbindir=${prefix}/bin' '--libdir=${prefix}/lib' '--includedir=${prefix}/include' '--oldincludedir=${prefix}/include' '--with-cross-build=some_path' '--host=wasm32-local-emscripten'

Possible cause

AutotoolsToolchain checks that build option has not been set yet. However, since it's a simple substring check, existing with-cross-build option fails this check

Example of affected recipe

ICU cross builds incorrectly because of this in some cases.

@franramirez688
Copy link
Contributor

franramirez688 commented Dec 1, 2022

Hi @ovostrikov

Thanks for reporting it because, indeed, it's a bug. I'll open a PR fixing this for the next release.

@SpaceIm
Copy link
Contributor

SpaceIm commented Dec 1, 2022

Something like this should be sufficient:

--- a/conan/tools/gnu/autotoolstoolchain.py
+++ b/conan/tools/gnu/autotoolstoolchain.py
@@ -186,8 +186,11 @@ class AutotoolsToolchain:
         configure_args.extend(self.configure_args)
         user_args_str = args_to_string(self.configure_args)
         for flag, var in (("host", self._host), ("build", self._build), ("target", self._target)):
-            if var and flag not in user_args_str:
-                configure_args.append('--{}={}'.format(flag, var))
+            if var:
+                arg = f"--{flag}="
+                if arg not in user_args_str:
+                    arg += var
+                    configure_args.append(arg)
 
         args = {"configure_args": args_to_string(configure_args),
                 "make_args":  args_to_string(self.make_args),

@jcar87 jcar87 removed their assignment Dec 1, 2022
@czoido czoido added this to the 1.57 milestone Dec 20, 2022
@franramirez688 franramirez688 self-assigned this Jan 11, 2023
SpaceIm added a commit to SpaceIm/conan-center-index that referenced this issue Feb 6, 2023
- use new stdcpp_library() instead of legacy one (since conan 1.54.0)
- write custom _sha256sum() function to avoid relying on legacy conans.tools.sha256sum() conan function
- remove workaround for conan-io/conan#12642 (fixed in conan 1.57.0)
- remove workaround for conan-io/conan#12153 (fixed in conan 1.54.0)
conan-center-bot pushed a commit to conan-io/conan-center-index that referenced this issue Feb 7, 2023
- use new stdcpp_library() instead of legacy one (since conan 1.54.0)
- write custom _sha256sum() function to avoid relying on legacy conans.tools.sha256sum() conan function
- remove workaround for conan-io/conan#12642 (fixed in conan 1.57.0)
- remove workaround for conan-io/conan#12153 (fixed in conan 1.54.0)
sabelka pushed a commit to sabelka/conan-center-index that referenced this issue Feb 12, 2023
- use new stdcpp_library() instead of legacy one (since conan 1.54.0)
- write custom _sha256sum() function to avoid relying on legacy conans.tools.sha256sum() conan function
- remove workaround for conan-io/conan#12642 (fixed in conan 1.57.0)
- remove workaround for conan-io/conan#12153 (fixed in conan 1.54.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment