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

Is the way how you handle $CROSS_COMPILE and $CC really correct? #24460

Open
CodingMarkus opened this issue May 22, 2024 · 2 comments
Open

Is the way how you handle $CROSS_COMPILE and $CC really correct? #24460

CodingMarkus opened this issue May 22, 2024 · 2 comments
Labels
branch: master Merge to master branch help wanted triaged: bug The issue/pr is/fixes a bug

Comments

@CodingMarkus
Copy link

When trying to cross compile lots of code, you typically have an environment where $CROSS_COMPILE and $CC are both set. E.g. I tried to cross-compile OpenSSL with emscripten and this caused the following issue:

emscripten will set both variables as follows

CROSS_COMPILE=/full/path/to/emscripten/em
CC=/full/path/to/emscripten/emcc

Most autoconf packages either don't know anything about cross compiling and just use $CC, which will work fine, or they are aware of $CROSS_COMPILE and will set

CC=${CROSS_COMPILE}cc

which will work as well.

But OpenSSL sets

CC=${CROSS_COMPILE}${CC}

which will result in

CC=/full/path/to/emscripten/em/full/path/to/emscripten/emcc

And that will of course fail and I wonder if that behavior is correct. Are you really supposed to append $CC to $CROSS_COMPILE and not just append cc (or cpp or ld) at the end?

I always thought that you either use $CC when set and only if not set, but $CROSS_COMPILE is set, you would use $CROSS_COMPILE to begin with and never use both, as setting $CC should always override which compile is being used. At least if $CC has an absolute path I'd always ignore $CROSS_COMPILE.

@CodingMarkus CodingMarkus added the issue: bug report The issue was opened to report a bug label May 22, 2024
@t8m
Copy link
Member

t8m commented May 22, 2024

Yeah, if we get CC from environment with an absolute path, we definitely should not prepend CROSS_COMPILE.

@CodingMarkus
Copy link
Author

Just FYI, I also created an issue with emscripten, as I wasn't sure if their way of setting up $CROSS_COMPILE and $CC is the expected way of doing things.

emscripten-core/emscripten#21969

I doubt there are any "official rules" for cross compiling, but maybe there are unofficial de-facto standards that have established over the years.

So just in case you think their way of setting variables might not be the right way, they would also be willing to change it and accept a patch I could give them. I'm just trying to figure out what the right thing to do is. It's always a bit tricky when things just don't work, but you can't be sure who's to blame, and sometimes the answer is "both" and sometimes it's actually "nobody".

I think the proposed logic regarding absolute paths makes perfect sense, but if you have any additional preferences on how to set up a better cross-compiler environment, I'd be happy to take your input on that other issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
branch: master Merge to master branch help wanted triaged: bug The issue/pr is/fixes a bug
Projects
None yet
Development

No branches or pull requests

2 participants