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
gollvm: aarch64 build/configuration support #33711
Comments
Initial RCA: function enumerateAttributes constructs clang command line with "-march=" option if the triple passed to capture-fcn-attributes equals to the default triple of the host platform, it works for x86-64 but not aarch64 due to the different behaviors of -march&-mtune/-mcpu between x86_64 and aarch64, -mcpu option is expected on aarch64. Enclosing a thread on clang-developers for reference. |
Thanks for the problem report. BTW, congratulations on getting an aarch64 version of gollvm working -- I hope you will contribute your work back to the project... I tried what you described from my x86_64 box, as follows:
and I am seeing something different from what you're seeing-- my output looks like: // DO NOT EDIT: this file auto-generated by the following command: // // ./capture-fcn-attributes -o /tmp/aheader.h -triples aarch64-unknown-linux-gnu // // in combination with clang: // // clang version 10.0.0 (trunk 368990) (llvm/trunk 369004) // typedef struct { const char *cpu; const char *attrs; } CpuAttrs; typedef struct { const char *triple; const CpuAttrs *cpuattrs; } TripleCpus; // triple: aarch64-unknown-linux-gnu static const CpuAttrs attrs0[] = { // first entry is default cpu { "generic", "+neon" }, { "cortex-a35", "+aes,+crc,+crypto,+fp-armv8,+neon,+sha2" }, { "cortex-a53", "+aes,+crc,+crypto,+fp-armv8,+neon,+sha2" }, { "cortex-a55", "+aes,+crc,+crypto,+dotprod,+fp-armv8,+fullfp16,+lse,+neon,+ras,+rcpc,+rdm,+sha2,+v8.2a" }, { "cortex-a57", "+aes,+crc,+crypto,+fp-armv8,+neon,+sha2" }, { "cortex-a65", "+aes,+crc,+crypto,+dotprod,+fp-armv8,+fullfp16,+lse,+neon,+ras,+rcpc,+rdm,+sha2,+v8.2a" }, { "cortex-a65ae", "+aes,+crc,+crypto,+dotprod,+fp-armv8,+fullfp16,+lse,+neon,+ras,+rcpc,+rdm,+sha2,+v8.2a" }, { "cortex-a72", "+aes,+crc,+crypto,+fp-armv8,+neon,+sha2" }, { "cortex-a73", "+aes,+crc,+crypto,+fp-armv8,+neon,+sha2" }, { "cortex-a75", "+aes,+crc,+crypto,+dotprod,+fp-armv8,+fullfp16,+lse,+neon,+ras,+rcpc,+rdm,+sha2,+v8.2a" }, { "cortex-a76", "+aes,+crc,+crypto,+dotprod,+fp-armv8,+fullfp16,+lse,+neon,+ras,+rcpc,+rdm,+sha2,+v8.2a" }, { "cortex-a76ae", "+aes,+crc,+crypto,+dotprod,+fp-armv8,+fullfp16,+lse,+neon,+ras,+rcpc,+rdm,+sha2,+v8.2a" }, { "cyclone", "+aes,+crypto,+fp-armv8,+neon,+sha2,+zcm,+zcz" }, { "exynos-m1", "+aes,+crc,+crypto,+fp-armv8,+neon,+sha2" }, { "exynos-m2", "+aes,+crc,+crypto,+fp-armv8,+neon,+sha2" }, { "exynos-m3", "+aes,+crc,+crypto,+fp-armv8,+neon,+sha2" }, { "exynos-m4", "+aes,+crc,+crypto,+dotprod,+fp-armv8,+fullfp16,+lse,+neon,+ras,+rdm,+sha2,+v8.2a" }, { "exynos-m5", "+aes,+crc,+crypto,+dotprod,+fp-armv8,+fullfp16,+lse,+neon,+ras,+rdm,+sha2,+v8.2a" }, { "falkor", "+aes,+crc,+crypto,+fp-armv8,+neon,+rdm,+sha2" }, { "kryo", "+aes,+crc,+crypto,+fp-armv8,+neon,+sha2" }, { "neoverse-e1", "+aes,+crc,+crypto,+dotprod,+fp-armv8,+fullfp16,+lse,+neon,+ras,+rcpc,+rdm,+sha2,+v8.2a" }, { "neoverse-n1", "+aes,+crc,+crypto,+dotprod,+fp-armv8,+fullfp16,+lse,+neon,+ras,+rcpc,+rdm,+sha2,+spe,+v8.2a" }, { "saphira", "+aes,+crc,+crypto,+fp-armv8,+lse,+neon,+ras,+rcpc,+rdm,+sha2,+spe,+v8.3a" }, { "thunderx", "+aes,+crc,+crypto,+fp-armv8,+neon,+sha2,+spe" }, { "thunderx2t99", "+aes,+crc,+crypto,+fp-armv8,+lse,+neon,+rdm,+sha2,+v8.1a" }, { "thunderxt81", "+aes,+crc,+crypto,+fp-armv8,+neon,+sha2,+spe" }, { "thunderxt83", "+aes,+crc,+crypto,+fp-armv8,+neon,+sha2,+spe" }, { "thunderxt88", "+aes,+crc,+crypto,+fp-armv8,+neon,+sha2,+spe" }, { "tsv110", "+aes,+crc,+crypto,+dotprod,+fp-armv8,+fp16fml,+fullfp16,+lse,+neon,+ras,+rdm,+sha2,+spe,+v8.2a" }, { "", "" } // sentinel }; const TripleCpus triples[] = { { "aarch64-unknown-linux-gnu", &attrs0[0] }, { "", nullptr } // sentinel }; Not sure about the quality of this info, but it at least seems plausible. How are you configuring your LLVM build (e.g. cmake args etc)? |
Hi Than, Thanks for looking into the issue. <1>. Issue of capture-fcn-attributes Seems to be a cross-compile issue which I'm not sure if gollvm intends to support. =============================================================== include <sys/cdefs.h>
1 error generated.Guess that might be due to no cross-compile tool chain in my x86 system. To summarize, we got two issues so far:
<2> About ArchCpusAttrs.h May I ask what's the suggestion to incorporate multiple triples? To have multiple ArchCpuAttrs.h, or just one having multiple triples, or let cmake generate it on the fly? <3> AArch64 porting |
The header issue should be easy to fix, I will send a CL. |
Change https://golang.org/cl/190899 mentions this issue: |
I sent a fix that should allow you to run the tool on x86_64 without having a cross-compile header environment set up. You asked about multiple triples: this should already be supported (just past a list of triples to the -triples flag). AArch64 porting -- the C abi is the interesting part. I am happy to provide reviews and suggestions if someone wants to work on it. |
Thanks Than, the fix works now, for both cross-compile and generating multiple triples' attrs on x86, I assume ArchCpusAttrs.h will stay pre-generated in gollvm, so plan to add the attr array for aarch64. |
And, just FYI, 'llc --version' might outputs a different default triple on x86_64 other than x86_64-unknown-linux-gnu, thus relying comparing the triple argument and the default triple to choose between -mcpu and -march may not work sometimes, but figure it's not a big deal. ============================================================ Optimized build. |
@thanm Are the exported libgo packages, i.e those .gox files, are platform independent, or supposed to support cross-platform importing? Thanks. |
Depends on what you mean by "platform-independent" and I guess. For example, consider this package:
The export data for the package will be different depending on whether you are building on a 32-bit architecture vs a 64-bit architecture. On the other hand it's not hard to imagine Go packages whose export data would be pretty much identical across platforms. Something else to keep in mind: export data for gccgo/gollvm now contains bodies of small inlinable functions, meaning that that code could contain assumptions about the host platform/target. Regarding "cross-platform importing", you could certainly build a package on one platform and then use it on another as experiment, but the toolchain is definitely not designed to support this in any meaningful or comprehensive way (due to issues like the one above). |
Thanks for the details, it helps much, especially the inline functions part. Got a few questions w.r.t aarch64 configuration, hopefully you could help here, thanks for your time.
|
[general remark -- this seems to be turning into a general discussion of gollvm as opposed to bug in capture-fcn-attributes, so maybe it should move to go-nuts mailing list?] For question 1: This is somewhat unexplored territory, but in general with GCC tools (both the gcc C and Go compilers) there is no notion of a single compiler that targets two different unrelated architectures-- you have to build and install each GCC cross compiler separately. In other words if you want compilers for x86, Arm, and PPC, you need three separate installs. With clang the model is that a single executable can target multiple architectures (assuming you didn't disable this at cmake time), and you can simply select the target using a command line option. For gollvm, I think the hope is that we can use the clang model instead of the GCC model for cross-compilation, but we haven't really fleshed out the driver support for any of that yet. Someone will need to think through the issues and make the necessary changes to the driver so that it can pick up Go libraries (ex: libgo.a) and C libraries (ex: libgcc.a) from the correct locations. Similarly we'll need to change the libgo build procedure to generate different architecure-specific variants and place them in the correct locations. I can help with these changes if you like. For question 2:
Currently this is handled by having cmake code that looks at the LLVM cmake variables containing OS/arch and translates them into the Go equivalents (e.g. "amd64" instead of "x86_64"). See /cmake/modules/GoVars.cmake. For question 3:
Yes, that sounds like the right place to make changes. For question 4:
That's fine. I think at the moment the contributor guide requires V5.0 or later for Clang, or V6.0 or later of GCC, but we can update it to require later versions for specific targets. Thanks, Than |
Thanks Than.
I may look into the cross-compilation requirement after finishing enabling aarch64 build, without abi part at first, trying to refine existing changes, which support building llvm-goc, tools and running unit-tests, to avoid redundancy. For the goarch issue, the same change as you proposed was made in GoVars.cmake, good to know we'll continue going with that way. Thanks for the answer to other questions. |
Change https://golang.org/cl/194997 mentions this issue: |
Change https://golang.org/cl/194998 mentions this issue: |
This CL serves as part of an initial change for enabling gollvm building on arm64 linux, the rest of the change will be covered by another one to the gollvm repo. Incorporate type definition of 'uint128' to 'runtime' and 'syscall' packges, the change is not specific to arm64 linux but made available for all platforms. Verified by building and unit-testing gollvm on linux x86-64 and arm64. Verified by building and checking gccgo on linux x86-64 and arm64. Fixes golang/go#33711 Change-Id: I4720c7d810cfd4ef720962fb4104c5641b2459c0 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@275919 138bc75d-0d04-0410-961f-82ee72b054a4
Hi Than, |
This CL serves as part of an initial change for enabling gollvm building on arm64 linux, the rest of the change will be covered by another one to the gollvm repo. Incorporate type definition of 'uint128' to 'runtime' and 'syscall' packges, the change is not specific to arm64 linux but made available for all platforms. Verified by building and unit-testing gollvm on linux x86-64 and arm64. Verified by building and checking gccgo on linux x86-64 and arm64. Fixes golang/go#33711 Change-Id: I4720c7d810cfd4ef720962fb4104c5641b2459c0 From-SVN: r275919
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Running the followings on aarch64 platform (using main go, llvm path is set in advance)
go build capture-fcn-attributes.go
./capture-fcn-attributes -o HeaderFile.h -triples aarch64-unknown-linux-gnu
HeaderFile.h only contains a 'generic' cpu
// triple: aarch64-unknown-linux-gnu
static const CpuAttrs attrs0[] = {
// first entry is default cpu
{ "generic", "+neon" },
{ "", "" } // sentinel
};
const TripleCpus triples[] = {
{ "aarch64-unknown-linux-gnu", &attrs0[0] },
{ "", nullptr } // sentinel
};
What did you expect to see?
To have capture-fcn-attributes support aarch64 platform, that is captures cpus supported by clang and their attributes, it's part of the gollvm enablement on aarch64.
What did you see instead?
The text was updated successfully, but these errors were encountered: