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

Question: can we build armv6 ABI for Alpine Linux using this toolchain #43

Closed
ghost opened this issue Apr 19, 2018 · 5 comments
Closed

Comments

@ghost
Copy link

ghost commented Apr 19, 2018

Apologies in advance if it is unrelated. We are trying to figure out how to get armv7-alpine-linux-musleabihf for Alpine Linux ARM32 v7 at https://github.com/dotnet/coreclr/issues/17468. The supported ABI by dotnet runtime atm is v7 for 32 bits and v8 for 64.

Since Alpine Linux armhf only provides armv6-alpine-linux-musleabihf for 32-bits targets (armv6 and armv7 devices), we were hoping to compile it ourselves; if possible.

Is this the right place to start? If not, could you suggest what would be the good place to start (if it is possible at all)?

Thanks!

@richfelker
Copy link
Owner

I don't understand what you're asking for. It sounds like you think armv6 and armv7 are different ABIs; they're not. They're just different ISA levels. A toolchain targeting armv6 produces binaries/libraries that are perfectly interlinkable with armv7 ones and vice versa; the only difference is whether additional armv7-only instructions are used (in which case the code only runs on armv7 and up as opposed to armv6 and up). If you have a toolchain targeting armv6, just adding -march=armv7-a to the CFLAGS will produce binaries optimized for armv7 (at the expense of being able to run on v6).

@ghost
Copy link
Author

ghost commented Apr 20, 2018

@richfelker, thanks for the information. I now get the concept of ABI compatibility between armv6 and armv7. :)

If Alpine distro only provides armv6-alpine-linux-musleabihf and CoreCLR codebase uses armv7-only instructions (dmb ish etc.), is there a way for us to still build CoreCLR in Alpine targeting ARMv7? https://pkgs.alpinelinux.org/contents?file=armv*&path=&name=&branch=edge&arch=armhf. In this case, do we need to still compile the toolchain (musl-cross-make) by ourselves with TARGET = armv7-linux-musleabihf, then using that toolchain compile CoreCLR repo (that also requires a different compiler; LLVM/clang)?

@richfelker
Copy link
Owner

You don't need a custom toolchain to do this, just -march=armv7-a.

@ghost
Copy link
Author

ghost commented Apr 20, 2018

Thanks. I tried sessing CFLAGS in CMake: set(CMAKE_C_FLAGS_INIT "${CMAKE_C_FLAGS_INIT} -march=armvv7-a -mcpu=cortex-a8") for alpine, however, when compiling on Alpine Linux 3.7 Linux aaf28ea95614 4.9.87-linuxkit-aufs #1 SMP Wed Mar 14 15:12:16 UTC 2018 armv7l Linux, I am still running into same invalid instructions error:

/coreclr/src/pal/../inc/volatile.h:154:5: error: invalid operand for instruction
    VOLATILE_MEMORY_BARRIER();
    ^
/coreclr/src/pal/../inc/volatile.h:79:49: note: expanded from macro 'VOLATILE_MEMORY_BARRIER'
#define VOLATILE_MEMORY_BARRIER() asm volatile ("dmb ish" : : : "memory")
                                                ^
<inline asm>:1:6: note: instantiated into assembly here
        dmb ish
            ^
1 error generated.

@ghost
Copy link
Author

ghost commented Apr 22, 2018

I made a simple test:

#include <stdio.h>
int main()
{
   asm volatile ("dmb ish" : : : "memory");
   return 0;
}

compiled with clang test.c -o test.exe -march=armv7-a, and it worked (without -march=armv7-a, it gives the error). It seems like something is wrong with CMake configuration of the project I am trying to build (something is overwriting CFlag). I will check.

Thanks for your help!

This issue was closed.
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

1 participant