[Compiler-rt] -march=aarch64 flag in gcc/clang

Hi,

I wonder if this is a valid flag in either clang/gcc.

The flag in question is “-march=aarch64”. I verified with latest tip and neither clang nor gcc fail to recognize this flag.

This piece of code is in cmake/config-ix.cmake in compiler-rt repo.

  • elseif(“${COMPILER_RT_TEST_TARGET_ARCH}” MATCHES “aarch64”)

  • test_target_arch(aarch64 “-march=aarch64”)

Anyone have any thoughts or any suggestions ? Currently this is blocking my compiler-rt build for aarch64-linux.

–Sumanth G

Ping

Hi Sumanth,

Christophe (cc'd) is seeing the same problems on his build. It seems
that r181130 (by Tim) has something to do with it, but I'm not sure.

I remember trying to build compiler-rt on AArch64 natively in
February, and even running the test-suite with it, so I'm sure it
should work (modulo regressions).

We desperately need a full buildbot on AArch64, but we also need to
common up all docs, especially the one in the sanitizer's page, since
they're not following what the rest of the LLVM community is doing,
ie. building all in one tree.

cheers,
--renato

Hi Sumanth,

Christophe (cc'd) is seeing the same problems on his build. It seems
that r181130 (by Tim) has something to do with it, but I'm not sure.

I remember trying to build compiler-rt on AArch64 natively in
February, and even running the test-suite with it, so I'm sure it
should work (modulo regressions).

Removing compiler-rt from projects sources enables cmake step to succeed.
The error message is:
[...]
CMake Error at projects/compiler-rt/cmake/config-ix.cmake:87 (message):
  Cannot compile for aarch64:
[...]
  Building CXX object CMakeFiles/cmTryCompileExec4274316732.dir/simple.cc.o

  /usr/bin/c++ -fPIC -fvisibility-inlines-hidden -Wall -W
  -Wno-unused-parameter -Wwrite-strings -Wcast-qual
  -Wno-missing-field-initializers -pedantic -Wno-long-long
  -Wno-maybe-uninitialized -Wno-comment -std=c++11 -ffunction-sections
  -fdata-sections -march=aarch64 -o
  CMakeFiles/cmTryCompileExec4274316732.dir/simple.cc.o -c
  /home/christophe.lyon/LLVM-sanitizers/build-cmake/CMakeFiles/simple.cc

  /home/christophe.lyon/LLVM-sanitizers/build-cmake/CMakeFiles/simple.cc:1:0:
  error: unknown value 'aarch64' for -march

Not sure what r181130 is supposed to do, though, since it introduces a
buggy option.

We desperately need a full buildbot on AArch64, but we also need to
common up all docs, especially the one in the sanitizer's page, since
they're not following what the rest of the LLVM community is doing,
ie. building all in one tree.

I should also mention that the doc at
http://clang.llvm.org/get_started.html
should be updated since it seems that configure is deprecated in favor of cmake.

Christophe.

Not sure what r181130 is supposed to do, though, since it introduces a
buggy option.

I didn't even have compiler-rt checked out when I was doing that; I
was just trying to get the base check-all working. As I recall that
option filtered through to some llvm-lit config files. Though it might
have been a .inc header.

Cheers.

Tim.

The point here is, if you are not building for Android.
You will hit this patch with cmake configuration -DCOMPILER_RT_TEST_TRIPLE=aarch64-linux-gnu

+ elseif("${COMPILER_RT_TEST_TARGET_ARCH}" MATCHES "aarch64")
+ test_target_arch(aarch64 "-march=aarch64")

I don't see "-march=aarch64" is a valid flag on either LLVM or GCC.
Should we replace this with a flag which is valid for only aarch64 and works for both LLVM and GCC ?

If the compiler-rt build works for others, I would like to see their cmake recipe ?

--Sumanth G

The point here is, if you are not building for Android.
You will hit this patch with cmake configuration -DCOMPILER_RT_TEST_TRIPLE=aarch64-linux-gnu

+ elseif("${COMPILER_RT_TEST_TARGET_ARCH}" MATCHES "aarch64")
+ test_target_arch(aarch64 "-march=aarch64")

I don't see "-march=aarch64" is a valid flag on either LLVM or GCC.
Should we replace this with a flag which is valid for only aarch64 and works for both LLVM and GCC ?

I think it should be -march=armv8-a

Sorry folks, that was totally my fault and I was too busy to realise
it. I have just changed it to "armv8-a" on r224362. I'm building it
now and it's working.

cheers,
--renato

Renato,
               I think there was a typo in the patch
- test_target_arch(aarch64 "-march=aarch64")
+ test_target_arch(aarch32 "-march=armv8-a")

It has to be aarch64 instead of aarch32 in the new patch.

--Sumanth G

Good grief! Sorry about that, should be fixed.

I am setting up an AArch64 full bot (LLVM+Clang+RT) check-all to make
sure that kind of thing doesn't happen any more.

Right now it's internal, and until I get the clearance, at least I'll
have something to bisect if things go sour.

cheers,
--renato

Hi Renato,

Are you sure? Armv8-a is aarch32, not aarch64. Something smells fishy there.

Cheers,

James

Hi Renato,

Are you sure? Armv8-a is aarch32, not aarch64. Something smells fishy there.

armv8-a is an architecture.
AArch32 and AArch64 are two different operating modes, both supported
by the armv8-a architecture.

Hi,

Right. I’m aware of that. But to Clang, “armv8-a” as an architecture is ARMv8/AArch32. Unless Clang has recently got a lot cleverer than it has been in the past.

James

Hi James,

That's for march, not target. You still need to specify an "aarch64"
target, or Clang would not even recognise -march=armv8. If you specify
"arm" for the target, then -march=armv8 will, indeed, be AArch32.

cheers,
--renato

Ah right, thanks Renato!