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] autotools.configure() uses --host and --build when cross-compiling #12705

Closed
paulharris opened this issue Dec 14, 2022 · 9 comments · Fixed by #12884
Closed

[bug] autotools.configure() uses --host and --build when cross-compiling #12705

paulharris opened this issue Dec 14, 2022 · 9 comments · Fixed by #12884
Assignees
Milestone

Comments

@paulharris
Copy link
Contributor

for flag, var in (("host", self._host), ("build", self._build), ("target", self._target)):

        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))

The old conans autotools_environment.py had parameters to set build=False host=False`, to prevent the configure script from being called with --host and --build.
That seems like a useful thing for one problematic recipe: libvpx
It has a custom configure script that does not handle --host and --build.

One way to workaround this is to patch the script so it accepts and ignores these parameters.
This sounds fragile.

The other way is to generate my own call to the configure script.
This seems appropriate and simpler than adding more cruft to the conan core.
conan-io/conan-center-index#13799

So, I thought I should raise this to see what you guys thought.

@SpaceIm
Copy link
Contributor

SpaceIm commented Dec 14, 2022

related to #12546

@franramirez688
Copy link
Contributor

Hi @paulharris @SpaceIm

Yeah, good point! I opened a PR some time ago that added those parameters at __init__() time so I think you could easily override/prune those ones whenever you want. Have a look at #12645
Could it do the trick? Or would you need anything else?

@paulharris
Copy link
Contributor Author

Looks ok to me, I'm still new to the conan codebase,
so I'd have to scan through the args and remove (or only keep) the items that start with --host= and --target=

Seems logical to me ... :) Might be nice to have a "remove_starting_with()" method to make that simple.
I suppose the only further problem is if AutotoolsToolChain decides to add more parameters that aren't supported, that would retrospectively break the recipe. But still nicer than having to craft the run() call in the recipe.

@franramirez688
Copy link
Contributor

Yes, I think it could be reasonable to have a little helper to prune those arguments. Indeed, your comment is related to @SpaceIm's one #12645 (comment)

Let me propose something in that PR.

@franramirez688
Copy link
Contributor

@paulharris

Only to clarify the issue's title, it says always, but it's only happening when cross-compiling, isn't it?

@franramirez688
Copy link
Contributor

franramirez688 commented Dec 14, 2022

I have proposed something like this in my previously mentioned PR:

at = AutotoolsToolchain(self)
# Pruning values if None is passed as a flag value
at.update_configure_args({"--build": None, "--host": None})

EDITED: It was a dictionary in the end.

@paulharris paulharris changed the title [bug] autotools.configure() always uses --host and --build [bug] autotools.configure() uses --host and --build when cross-compiling Dec 14, 2022
@paulharris
Copy link
Contributor Author

I like it :) but the first one ... if you only want to prune host, then if you don't specify 'build' then it would call with build=None due to default arguments?
ie at.update_configure_args( host=None ) would also prune build ?

@franramirez688
Copy link
Contributor

franramirez688 commented Dec 14, 2022

I like it :) but the first one ... if you only want to prune host, then if you don't specify 'build' then it would call with build=None due to default arguments? ie at.update_configure_args( host=None ) would also prune build ?

Not at all. You pass only the arguments that you want to change, the rest of them are unaffected.
For instance:

at = AutotoolsToolchain(self)
# at.configure_args -> ['--host=wasm32-local-emscripten', '--build=x86_64-linux-gnu', '--target=aarch64-linux-android']
at.update_configure_args({"--host": None, "--target": "my_triplet"})
# configure_args -> ['--build=x86_64-linux-gnu', '--target=my_triplet']

EDITED: It was a dictionary in the end.

@franramirez688
Copy link
Contributor

franramirez688 commented Jan 11, 2023

Closed by #12884

Finally, it'll be something like this:

at = AutotoolsToolchain(self)
at.update_configure_args({"--build": None,   # remove --build flag
                          "--host": "whatever"  # update existing --host one
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants