Skip to content

Build changes for ARM64 #534

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Build changes for ARM64 #534

wants to merge 12 commits into from

Conversation

ayrtonm
Copy link
Contributor

@ayrtonm ayrtonm commented Apr 7, 2025

No description provided.

@fw-immunant
Copy link
Contributor

The x86 switch of PartitionAlloc to libc++ breaks x86 CI. It might just need to be installed.

@ayrtonm
Copy link
Contributor Author

ayrtonm commented Apr 11, 2025

The x86 switch of PartitionAlloc to libc++ breaks x86 CI. It might just need to be installed.

Should be easy enough to just switch back to libstdc++ on x86.

@fw-immunant
Copy link
Contributor

Should this be changing our submodule to point at https://github.com/immunant/IA2-glibc? Testing this locally I see the glibc configure failing at its gcc version check step:
checking if llvm-project/build/bin/clang-19 -target aarch64-linux-gnu -ffixed-x18 -march=armv8.5-a+memtag --rtlib=compiler-rt -O3 -B/usr/aarch64-linux-gnu/bin/ is sufficient to build libc... no

@fw-immunant fw-immunant force-pushed the am/arm_build branch 17 times, most recently from 2ac6a35 to f4eaf4d Compare April 16, 2025 21:11
@fw-immunant
Copy link
Contributor

Rebased one more time to incorporate the various AArch64 fixes that just landed in main; hopefully everything stays green. 🤞

ayrtonm and others added 7 commits April 17, 2025 14:32
This commit switches PartitionAlloc from GNU libstdc++ to LLVM libc++ since we
need to use dependencies built with our clang fork on ARM.

It does not do so on x86_64 because switching C++ stdlib requires both compile-
(-stdlib=libc++) and link-time changes, and we don't expect the compile-time
flags to be present when building for x86_64.
this was needed to ensure dependents of partition-alloc also link in LLVM libcxx
it's now correctly included in partition-alloc's target_link_libraries
we need to build glibc with our modified clang toolchain for ARM
rpath_link is inherited by static dependencies, so it should be used for libs and does nothing for executables.

then pass only -rpath when linking the final executable.
ayrtonm and others added 5 commits April 17, 2025 14:32
this normalizes paths so that both rebuilt and prebuilt glibc leave binaries at
/lib under the glibc sysroot. otherwise, we would need to make our
LD_LIBRARY_PATH for qemu differ depending on whether glibc was prebuilt or not.

that said, the glibc `make install` invocation does technically fail because it
cannot not run the AArch64 ldconfig. this does not fail the build as a whole, so
we leave it for now.
… glibc match

also remove it from our LD_LIBRARY_PATH when invoking qemu as libc.so.6 and
ld-linux-aarch64.so.1 now live in /lib (rather than /usr/lib) under the sysroot
we must link with the one built with our toolchain, whether prebuilt or from building glibc
@@ -203,11 +208,13 @@ jobs:
-DCMAKE_OBJCOPY=/usr/bin/llvm-objcopy-15 \
-DCMAKE_C_FLAGS="$cross_flags" \
-DCMAKE_CXX_FLAGS="$cross_flags" \
-DCMAKE_EXE_LINKER_FLAGS="$cross_link_flags -lm -Wl,-rpath-link,${rtlibs_dir}/lib" \
-DCMAKE_SHARED_LINKER_FLAGS="$cross_link_flags -Wl,-rpath,${rtlibs_dir}/lib" \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was switching -Wl,-rpath and -Wl,-rpath-link in these two lines intentional?

@@ -12,7 +12,7 @@ else()
endif()
set(QEMU_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR}
"-one-insn-per-tb"
"-L" "${CMAKE_BINARY_DIR}/external/glibc/sysroot/usr/"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the sysroot not include the headers anymore? Why are we removing the usr suffix?

@@ -55,15 +55,18 @@ target_link_options(libia2 INTERFACE
set_property(TARGET libia2 PROPERTY INTERFACE_LINK_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/padding.ld ${CMAKE_CURRENT_BINARY_DIR}/dynsym.syms)

if (LIBIA2_AARCH64)
set(SYSROOT_BIN_DIR ${CMAKE_BINARY_DIR}/external/glibc/sysroot)
set(LIBC_PATH ${SYSROOT_BIN_DIR}/lib/libc.so.6)
set(LD_LINUX_PATH ${SYSROOT_BIN_DIR}/lib/ld-linux-aarch64.so.1)
if (LIBIA2_REBUILD_GLIBC)
ExternalProject_Add(glibc
SOURCE_DIR ${CMAKE_SOURCE_DIR}/external/glibc
BINARY_DIR ${CMAKE_BINARY_DIR}/external/glibc
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env
# ffixed-x18 has to be set here instead of CFLAGS for it to apply to all files
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/ffixed-x18/compiler flags in the comment

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