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

Makefile: Fix macOS cross-compilation #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

EllaFoxo
Copy link
Contributor

@EllaFoxo EllaFoxo commented Oct 23, 2024

On macOS, the clang compiler is the default for C++ sources. Therefore, we also require the CROSS_PREFIX to be set here as well.

This updates the Makefile, but also fixes the check-gcc script, so that it understands we are cross compiling with the prefixed readelf binary.

On macOS, the clang compiler is the default for C++ sources. Therefore, we also require the CROSS_PREFIX to be set here as well. This updates the Makefile, but also fixes the check-gcc script, so that it understands we are cross compiling with the prefixed readelf binary.

Signed-off-by: Ella Fox <[email protected]>
@EllaFoxo EllaFoxo force-pushed the fix/macos-cross-compile branch from 5148b02 to c9b6743 Compare October 23, 2024 18:58
@Arksine
Copy link
Owner

Arksine commented Oct 24, 2024

Thanks. I'm ok with the change to the makefile, however I don't believe the CROSS_PREFIXmakefile variable propagates to the environment, so the change to check-gcc.sh won't change readelf binary. Presumably its fine to use the native readelf to perform the check anyway.

@EllaFoxo
Copy link
Contributor Author

It does propagate, as I tested the script being called from the Makefile, and it is able to find the readelf binary correctly

@Arksine
Copy link
Owner

Arksine commented Oct 24, 2024

Interesting. My understanding of make is that it doesn't set environment variables unless you explicit use export. When testing on Ubuntu echoing the cross prefix in check-gcc.sh results in an empty string, which is what I would expect.

@EllaFoxo
Copy link
Contributor Author

EllaFoxo commented Oct 24, 2024

I think Makefiles behave differently, unless there is something we're doing different. I'm running the make commands with CROSS_PREFIX="arm-none-eabi-" make menuconfig etc, which might be why it's picked up. I'll look into it further

@Arksine
Copy link
Owner

Arksine commented Oct 24, 2024

Ah, you are explicitly setting the CROSS_PREFIX in the environment prior to running make. Generally that shouldn't be necessary, the CROSS_PREFIX variable is set by the makefile located platform directory.

I suppose that is fine, however I wouldn't expect users to do this. Does MacOS not have a native readelf binary? Or put differently, does the build fail if you omit the CROSS_PREFIX="arm-none-eabi-" from the command?

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

Successfully merging this pull request may close these issues.

2 participants