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

Build fails on i386 #4875

Open
yurivict opened this issue Feb 24, 2025 · 9 comments
Open

Build fails on i386 #4875

yurivict opened this issue Feb 24, 2025 · 9 comments

Comments

@yurivict
Copy link

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

  • Operating System & Odin Version: FreeBSD 14.2 2025-02

Current Behavior

In file included from src/main.cpp:88:
src/llvm_backend.cpp:2959:3: error: use of undeclared identifier 'LLVMInitializeAArch64TargetInfo'
 2959 |                 LLVMInitializeAArch64TargetInfo();
      |                 ^
src/llvm_backend.cpp:2960:3: error: use of undeclared identifier 'LLVMInitializeAArch64Target'
 2960 |                 LLVMInitializeAArch64Target();
      |                 ^
src/llvm_backend.cpp:2961:3: error: use of undeclared identifier 'LLVMInitializeAArch64TargetMC'
 2961 |                 LLVMInitializeAArch64TargetMC();
      |                 ^
src/llvm_backend.cpp:2962:3: error: use of undeclared identifier 'LLVMInitializeAArch64AsmPrinter'
 2962 |                 LLVMInitializeAArch64AsmPrinter();
      |                 ^

Failure Logs

https://pkg-status.freebsd.org/beefy17/data/main-i386-default/p413ee6de2f09_s65c573e47c4/logs/odin-lang-2025.02.log

@JesseRMeyer
Copy link

Does FreeBSD's LLVM installation not support i386?

Note that FreeBSD considers that platform deprecated:

https://www.freebsd.org/releases/14.0R/relnotes/
General Notes Regarding Future FreeBSD Releases

FreeBSD 15.0 is not expected to include support for 32-bit platforms other than armv7. The armv6, i386, and powerpc platforms are deprecated and will be removed. 64-bit systems will still be able to run older 32-bit binaries.

@yurivict
Copy link
Author

yurivict commented Feb 24, 2025

Does FreeBSD's LLVM installation not support i386?

The build calls *AArch* functions on i386

64-bit systems will still be able to run older 32-bit binaries.

While FreeBSD 14 and 13 are available i386 builds will be performed. This will still last for a few years.

@JesseRMeyer
Copy link

JesseRMeyer commented Feb 24, 2025

https://github.com/odin-lang/Odin/blob/faaa05536f070093802fbdc4f7f62e7bd8439b64/src/llvm_backend.cpp#L2934C1-L2949C9

Odin does not call these functions on i386 necessarily, but they are referenced in the build. I think this means that the LLVM library on your system does not export the symbols and thus become "undeclared identifiers".

Odin can build for different targets via the build flag -target:, meaning that i386 should be buildable as a target from AMD64 and vise versa, but for this to work your LLVM install has to have support for both. LLVM can be configured to support a variable number of targets. So it seems to me that your LLVM install (presumably the default packaged by FreeBSD) lacks support for AArch64.

Unless I'm mistaken and someone can correct me.

@yurivict
Copy link
Author

The code appears to use the TargetArch_arm64 context on i386 in src/llvm_backend.cpp

The i386 VM has full support for i386.

@laytan
Copy link
Collaborator

laytan commented Feb 24, 2025

These symbols are linked because cross-compilation exists, they are used if you -target: to an aarch64 target. Your LLVM package does not seem to export these functions. I don't think this is something we need to fix on our side.

@laytan
Copy link
Collaborator

laytan commented Feb 24, 2025

We could check availability before enabling them, and print an error if somebody tries a -target: on it. But it does seems weird to me that the LLVM package doesn't export them.

@yurivict
Copy link
Author

It might be that cross-compilation is turned off in this i386 build of llvm. Other architectures might have the same options.

In order to work around this problem I suggest that you add a new cmake option: ODIN_ENABLE_CROSS_COMPILATION, ON by default.

When this option would be disabled Odin would not use LLVM functions for other architectures, and it would fail at the run-time with a graceful error message when users would attempt to use cross compilation options.

We can adjust the value of this option in the FreeBSD port based on the architecture.

@laytan
Copy link
Collaborator

laytan commented Feb 25, 2025

We don't use cmake, I also don't think that's even needed. You can just ifdef it in the code right?

@yurivict
Copy link
Author

We don't use cmake, I also don't think that's even needed.

There should be a way to pass build options, like in most projects.

You can just ifdef it in the code right?

Me? I don't have resources, I am only a port maintainer.

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