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

Support testing of non-host architecture via qemu #267

Open
davidlattimore opened this issue Jan 2, 2025 · 5 comments
Open

Support testing of non-host architecture via qemu #267

davidlattimore opened this issue Jan 2, 2025 · 5 comments

Comments

@davidlattimore
Copy link
Owner

@marxin is in the process of porting to aarch64. Not all the tests pass on ARM yet, but some do.

It'd be great if we could run tests for arm even if we're developing on x86-64. This should be possible with qemu. For some helpful (debian / ubuntu based) instructions, see this blog post.

@andrewdavidmackenzie - perhaps this is something you might be interested in?

I'm not sure exactly what it might look like. One possibility is that our tests could have an instruction in them to specify which architectures the test should run on. e.g. //#Arch:x86_64, aarch64. We'd then need to add additional flags to the compiler (and possibly linker) to specify the architecture. Then, when running the resulting binary, if the architecture isn't the same as the host, we'd run the binary using qemu-aarch64 or equivalent.

@andrewdavidmackenzie
Copy link
Contributor

andrewdavidmackenzie commented Jan 2, 2025 via email

@davidlattimore
Copy link
Owner Author

I was thinking more the other way around - executing arm binaries on an x86-64 Linux machine, but it could plausibly work both ways.

Rather than adding the option to all tests, one possibility would be to make the option have a default value, which initially could be "x86_64, aarch64", then override that default for the tests that are x86_64-specific (e.g. because they're written in x86 assembly), or which just don't yet pass on aarch64.

@marxin
Copy link
Collaborator

marxin commented Jan 4, 2025

Adding the qemu support to integration tests might be non-trivial as one needs to properly install cross GCC/Clang, glibc and I am not sure about the qemu when it comes to the dynamically linked binary.

An initial step for me would be porting most of the integration tests away from the assembly to C/Rust code that can be run by both platforms. The second step, in my opinion, can be porting the remaining assembly bits to aarch64 as well. Similarly to what I did here:

#elif defined(__aarch64__)

@davidlattimore
Copy link
Owner Author

At least on ubuntu, installing the required packages for cross compiling to arm was pretty easy - just ran sudo apt install qemu-user qemu-user-static gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu binutils-aarch64-linux-gnu-dbg build-essential (from the linked blog post). Not sure we actually need all of that. e.g. qemu-user-static for example is only needed if running the binaries directly, but there's no real reason we'd need to do that from the integration tests.

I was able to run a dynamically linked aarch64 program by following the instructions in the post.

I agree, that reducing the number of x86-64-specific asm tests would be very helpful for porting.

@marxin
Copy link
Collaborator

marxin commented Jan 5, 2025

Then it sounds cool and having the AArch64 coverage in CI would be great.

Related PR: #280

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