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

Why the need to separately compile aarch64 and x86_64? #61

Open
juanrunzio opened this issue Jan 24, 2025 · 4 comments
Open

Why the need to separately compile aarch64 and x86_64? #61

juanrunzio opened this issue Jan 24, 2025 · 4 comments

Comments

@juanrunzio
Copy link
Contributor

juanrunzio commented Jan 24, 2025

We are working on a project and while we were trying to create a config-wrapper we had a doubt about why it is necessary to compile both architectures separately if in the end we will have a single binary.
Considering that the cosmopolitan README instructions say that cosmocc generates an APE for you, why does superconfigure compile separately and then put them together?

@juanrunzio juanrunzio changed the title Compiling aarch64 and x86_64 Why the need to separately compile aarch64 and x86_64? Jan 24, 2025
@ahgamut
Copy link
Owner

ahgamut commented Jan 24, 2025

cosmocc generating an APE works quite well for projects that don't make too many checks about the host system: for example lang/lua can be built by setting CC=cosmocc.

However, some larger projects (for example gnutls, python) may request some specific details about the host compiler and target architecture, because they may have some architecture-specific ASM or optimizations. IIRC some of packages even compile different files depending on what architecture is being targeted.

The build steps for such packages error out if CC=cosmocc is provided (assume x86_64 at config time, but aarch64 at build time etc.). Thus we run a build for each architecture and then combine via apelink.

@ahgamut
Copy link
Owner

ahgamut commented Jan 24, 2025

The process used in this repo precedes cosmocc, and is also more flexible: we can handle arch-specific differences in a straightforward manner for each step of the build process.

@franalbani
Copy link

In case one has a project were the difference is not relevant, which recipe should take as an starting point? lang/lua/BUILD.mk ?

Is there any superconfigure subproject currently delegating all this to cosmocc?

@ahgamut
Copy link
Owner

ahgamut commented Jan 24, 2025

Is there any superconfigure subproject currently delegating all this to cosmocc?

No, every project in this repo builds x86_64 and aarch64 separately, and combines via apelink.

In case one has a project were the difference is not relevant, which recipe should take as an starting point?

I'd recommend building for each arch separately, like the recipes here, because it is easier to test.

For a build using just cosmocc, you don't need this whole repo, just cosmocc.zip. As an example, you can download the Lua source, set CC=cosmocc and run make to get a build.

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

No branches or pull requests

3 participants