Skip to content

CustomMain NativeAot test doesn't support cross-arch compilation #82320

Closed
@sbomer

Description

@sbomer

The testcase added in #81873 doesn't currently work when cross-building tests from x64 for arm64.

When I do a cross-build of the tests, this is the command-line that gets used to compile the native object:
cd /home/svbomer/src/runtime/artifacts/tests/coreclr/obj/linux.arm64.Release/Native/nativeaot/CustomMain && /usr/bin/clang++-15 -DDISABLE_CONTRACTS -DHOST_64BIT -DHOST_AMD64 -DHOST_UNIX -DNDEBUG -DTARGET_64BIT -DTARGET_AMD64 -DTARGET_LINUX -DTARGET_UNIX -DURTBLDENV_FRIENDLY=Retail -D_FILE_OFFSET_BITS=64 -I/home/svbomer/src/runtime/src/native -I/home/svbomer/src/runtime/src/tests/Common/Platform -O3 -DNDEBUG -fPIC -O3 -g -Wall -Wno-null-conversion -fno-omit-frame-pointer -fms-extensions -fwrapv -fstack-protector-strong -Werror -Wno-unused-variable -Wno-unused-value -Wno-unused-function -Wno-tautological-compare -Wno-unknown-pragmas -Wimplicit-fallthrough -Wno-invalid-offsetof -Wno-unused-but-set-variable -ffp-contract=off -fno-rtti -Wno-unknown-warning-option -ferror-limit=4096 -Wno-unused-private-field -Wno-constant-logical-operand -Wno-pragma-pack -Wno-incompatible-ms-struct -Wno-reserved-identifier -Wno-unsafe-buffer-usage -Wno-single-bit-bitfield-constant-conversion -Wno-cast-function-type-strict -fsigned-char -fvisibility=hidden -ffunction-sections -std=gnu++11 -MD -MT nativeaot/CustomMain/CMakeFiles/CustomMainNative.dir/CustomMainNative.cpp.o -MF CMakeFiles/CustomMainNative.dir/CustomMainNative.cpp.o.d -o CMakeFiles/CustomMainNative.dir/CustomMainNative.cpp.o -c /home/svbomer/src/runtime/src/tests/nativeaot/CustomMain/CustomMainNative.cpp

Notice the -DTARGET_AMD64. The test gets compiled for amd64 even though I am asking to build for arm64:

ROOTFS_DIR=`pwd`/../crossrootfs/arm64 ./src/tests/build.sh -arm64 nativeaot Release test nativeaot/CustomMain/CustomMain.csproj

which results in downstream errors later in the build:

/usr/bin/aarch64-linux-gnu-ld: /home/svbomer/src/runtime/artifacts/tests/coreclr/linux.arm64.Release/nativeaot/CustomMain/CustomMain/libCustomMainNative.a(CustomMainNative.cpp.o): Relocations in generic ELF (EM: 62)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions