-
Notifications
You must be signed in to change notification settings - Fork 667
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
Fix build issues when compiling WAMRC as a cross-compiler #4112
base: main
Are you sure you want to change the base?
Fix build issues when compiling WAMRC as a cross-compiler #4112
Conversation
AOT reloc functions are used only when loading AOT WebAssembly modules on target, not during AOT compilation. Original code led to build issues when building wamrc as cross-compiler, using arm header on x86 build.
c09a912
to
55bdc66
Compare
|
The header file is required at compile-time, but this is not about cross-compiling wamrc—rather, it's about building a cross-compiler. In this scenario, we have both a host and a target architecture (e.g., host: x86_64, target: armv7). However, the CMake files currently use a single variable, WAMR_BUILD_PLATFORM, for both, even though it should only define the target platform. This causes issues, such as the one mentioned above. With these commits and |
@@ -275,6 +271,8 @@ else () | |||
message ("-- Lib wasi-threads disabled") | |||
endif () | |||
|
|||
set (WAMR_AOT_COMPILER 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a similar naming pattern WAMR_BUILD_WAMR_COMPILER
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") | ||
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32") | ||
endif () | ||
# Add -m32 flag if compiling on 64-bit system for 32-bit x86 target |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that the information regarding Add -fPIC flag if build as 64-bit has been deleted. Was this done on purpose?
*/ | ||
|
||
#include "aot_reloc.h" | ||
#include <stdlib.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better remove <stdlib.h>. bh_platform.h in aot_runtime.h will do.
@@ -398,4 +396,4 @@ else() | |||
${UV_A_LIBS}) | |||
endif() | |||
|
|||
install (TARGETS wamrc DESTINATION bin) | |||
install (TARGETS wamrc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this done on purpose? Others might need it.
Description
This pull request addresses issues encountered when compiling WAMRC to be a cross-compiler—running on a PC while targeting an embedded ARM platform. The key fixes include:
Fixes in This PR
-m32 compiler flag
-m32
flag was previously added unconditionally for 32-bit targets, causing issues for non-x86 platforms.-m32
is only added when targeting a 32-bit x86 platform (X86_32
), ensuring it is only applied where supported.Improved PIC Flag Handling:
-fPIC
) based onWAMR_BUILD_PLATFORM
was overly complex.AOT Relocation Functions:
<arm_neon.h>
) that are not available on a PC.SIMD Compilation Issues: