Hi,
I'm trying to compile rosetta w/ scons by hacking the tools/build/setup_platforms.py, tools/build/basic.settings and tools/build/options.settings.
#tools/build/setup_platforms.py:162
def select_arch(supported, os, requested, expected = None):
"""Figure out which processor is being run on.
Caveats:
- There is currently no way to distinguish Intel x86 from AMD x86.
- It's not clear if uname() can tell if a platform is 64-bit.
"""
processor_translation = {
# Results from platform.processor()
"i386": "x86",
"i486": "x86",
"i586": "x86",
"i686" : "x86",
"x86_64" : "x86",
"ppc64" : "ppc64",
"powerpc" : "ppc",
# Added by Yinying for aarch64 testing
"aarch64": "aarch64",
# Results from os.uname()['machine']
# This isn't strictly true. But we are not currently distinguishing
# between AMD and Intel processors.
"athlon" : "x86",
"Power Macintosh" : "ppc",
#tools/build/setup_platforms.py:220
def select_arch_size(supported, os, arch, requested):
"""Figure out the bit-width of the current processor architecture.
There's no obvious portable way to do this. By default
just assume the requested size is correct.
"""
actual = _get_arch_size()
print(f"fetch actual_size={actual}")
actual = {
"32bit" : "32",
"64bit" : "64",
# Added by Yinying for aarch64 testing
"aarch64": "64",
"arm64": "64",
"arm": "32",
# XXX: We are guessing here. This may prove incorrect
"i386" : "32",
"i486" : "32",
"i586" : "32",
"i686" : "32",
# XXX: What do 64 bit Macs show?
"Power Macintosh" : "32",
}.get(actual, "<unknown>")
and
# tools/build/basic.settings:978
# added by Yinying for aarch64 cross-compilation
"gcc, x86, debug_aarch" : {
"appends" : {
"flags" : {
# Hisilicon march: https://www.hisilicon.com/cn/products/Kunpeng/Huawei-Kunpeng/Huawei-Kunpeng-920
# mturn: https://support.huaweicloud.com/prtg-kunpenghpcs/kunpengmafft_02_0007.html
# aarch64 default setting: https://blog.csdn.net/xclshwd/article/details/90713747
"compile" : [
"march=armv8.2-a",
"mtune=tsv110",
],
},
},
"overrides" : {
"cc" : '/path/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-gcc',
"cxx" : '/path/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-g++',
"link" : '/path/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-ld',
},
"removes" : {
"flags" : {
"compile" : [
"march=core2",
"mtune=generic",
"malign-double",
"march=pentium4",
"march=athlon",
"mtune=itanium2"
],
},
},
},
for options.settings I simply added aarch64-none-linux-gnu-gcc and aarch64 into cxx and arch, together w/ debug_aarch as a mode for cross-compilation.
after that the compilation started by the following command as a test.
./scons.py -j 30 mode=debug_aarch
the error occurs:
/path/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-gcc -o build/external/debug_aarch/linux/3.10/64/x86/gcc/8.5/default/libxml2/trio.os -c -std=c99 -isystem external/boost_submod/ -isystem external/ -isystem external/include/ -isystem external/dbio/ -isystem external/libxml2/include -isystem external/rdkit -pipe -Wno-long-long -Wno-strict-aliasing -march=armv8.2-a -mtune=tsv110 -DTRIO_HAVE_CONFIG_H -fPIC -DBOOST_ERROR_CODE_HEADER_ONLY -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS -DBOOST_DISABLE_THREADS -DPTR_STD -Iexternal/include external/libxml2/trio.c
.......
external/libxml2/triostr.c: In function 'trio_equal':
external/libxml2/trio.c: In function 'trio_printfv':
external/libxml2/triostr.c:411:20: warning: implicit declaration of function 'strcasecmp'; did you mean 'strncmp'? [-Wimplicit-function-declaration]
411 | return (0 == strcasecmp(first, second));
| ^~~~~~~~~~
| strncmp
external/libxml2/triostr.c: In function 'trio_equal_max':
external/libxml2/triostr.c:534:20: warning: implicit declaration of function 'strncasecmp'; did you mean 'strncmp'? [-Wimplicit-function-declaration]
534 | return (0 == strncasecmp(first, second, max));
| ^~~~~~~~~~~
| strncmp
external/libxml2/trio.c:3699:59: error: incompatible type for argument 5 of 'TrioFormat'
3699 | return TrioFormat(stdout, 0, TrioOutStreamFile, format, NULL, args);
| ^~~~
| |
| void *
In file included from external/libxml2/trio.c:47:
external/libxml2/trio.c:3435:22: note: expected 'va_list' but argument is of type 'void *'
3435 | TRIO_VA_LIST_PTR arglist,
| ^
external/libxml2/triodef.h:172:58: note: in definition of macro 'TRIO_ARGS6'
172 | # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6)
| ^~
external/libxml2/trio.c: In function 'trio_fprintfv':
external/libxml2/trio.c:3772:57: error: incompatible type for argument 5 of 'TrioFormat'
3772 | return TrioFormat(file, 0, TrioOutStreamFile, format, NULL, args);
| ^~~~
| |
| void *
In file included from external/libxml2/trio.c:47:
external/libxml2/trio.c:3435:22: note: expected 'va_list' but argument is of type 'void *'
3435 | TRIO_VA_LIST_PTR arglist,
| ^
external/libxml2/triodef.h:172:58: note: in definition of macro 'TRIO_ARGS6'
172 | # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6)
| ^~
external/libxml2/trio.c: In function 'trio_dprintfv':
external/libxml2/trio.c:3842:66: error: incompatible type for argument 5 of 'TrioFormat'
3842 | return TrioFormat(&fd, 0, TrioOutStreamFileDescriptor, format, NULL, args);
| ^~~~
| |
| void *
In file included from external/libxml2/trio.c:47:
external/libxml2/trio.c:3435:22: note: expected 'va_list' but argument is of type 'void *'
3435 | TRIO_VA_LIST_PTR arglist,
| ^
external/libxml2/triodef.h:172:58: note: in definition of macro 'TRIO_ARGS6'
172 | # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6)
| ^~
external/libxml2/trio.c: In function 'trio_cprintfv':
external/libxml2/trio.c:3904:60: error: incompatible type for argument 5 of 'TrioFormat'
3904 | return TrioFormat(&data, 0, TrioOutStreamCustom, format, NULL, args);
| ^~~~
| |
| void *
In file included from external/libxml2/trio.c:47:
external/libxml2/trio.c:3435:22: note: expected 'va_list' but argument is of type 'void *'
3435 | TRIO_VA_LIST_PTR arglist,
| ^
external/libxml2/triodef.h:172:58: note: in definition of macro 'TRIO_ARGS6'
172 | # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6)
| ^~
external/libxml2/trio.c: In function 'trio_sprintfv':
external/libxml2/trio.c:3984:64: error: incompatible type for argument 5 of 'TrioFormat'
3984 | status = TrioFormat(&buffer, 0, TrioOutStreamString, format, NULL, args);
| ^~~~
| |
| void *
In file included from external/libxml2/trio.c:47:
external/libxml2/trio.c:3435:22: note: expected 'va_list' but argument is of type 'void *'
3435 | TRIO_VA_LIST_PTR arglist,
| ^
external/libxml2/triodef.h:172:58: note: in definition of macro 'TRIO_ARGS6'
172 | # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6)
| ^~
external/libxml2/trio.c: In function 'trio_snprintfv':
external/libxml2/trio.c:4077:41: error: incompatible type for argument 5 of 'TrioFormat'
4077 | TrioOutStreamStringMax, format, NULL, args);
| ^~~~
| |
| void *
In file included from external/libxml2/trio.c:47:
external/libxml2/trio.c:3435:22: note: expected 'va_list' but argument is of type 'void *'
3435 | TRIO_VA_LIST_PTR arglist,
| ^
external/libxml2/triodef.h:172:58: note: in definition of macro 'TRIO_ARGS6'
172 | # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6)
| ^~
external/libxml2/trio.c: In function 'trio_printv_ref':
external/libxml2/trio.c:4985:57: error: incompatible type for argument 3 of 'TrioFormatRef'
4985 | return TrioFormatRef((trio_reference_t *)ref, format, NULL, argarray);
| ^~~~
| |
| void *
In file included from external/libxml2/trio.c:47:
external/libxml2/trio.c:3407:22: note: expected 'va_list' but argument is of type 'void *'
3407 | TRIO_VA_LIST_PTR arglist,
| ^
external/libxml2/triodef.h:170:46: note: in definition of macro 'TRIO_ARGS4'
170 | # define TRIO_ARGS4(list,a1,a2,a3,a4) (a1,a2,a3,a4)
| ^~
external/libxml2/trio.c: In function 'trio_scanfv':
external/libxml2/trio.c:6643:13: error: incompatible type for argument 5 of 'TrioScan'
6643 | format, NULL, args);
| ^~~~
| |
| void *
In file included from external/libxml2/trio.c:47:
external/libxml2/trio.c:6397:22: note: expected 'va_list' but argument is of type 'void *'
6397 | TRIO_VA_LIST_PTR arglist,
| ^
external/libxml2/triodef.h:172:58: note: in definition of macro 'TRIO_ARGS6'
172 | # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6)
| ^~
external/libxml2/trio.c: In function 'trio_fscanfv':
external/libxml2/trio.c:6697:13: error: incompatible type for argument 5 of 'TrioScan'
6697 | format, NULL, args);
| ^~~~
| |
| void *
In file included from external/libxml2/trio.c:47:
external/libxml2/trio.c:6397:22: note: expected 'va_list' but argument is of type 'void *'
6397 | TRIO_VA_LIST_PTR arglist,
| ^
external/libxml2/triodef.h:172:58: note: in definition of macro 'TRIO_ARGS6'
172 | # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6)
| ^~
external/libxml2/trio.c: In function 'trio_dscanfv':
external/libxml2/trio.c:6748:13: error: incompatible type for argument 5 of 'TrioScan'
6748 | format, NULL, args);
| ^~~~
| |
| void *
In file included from external/libxml2/trio.c:47:
external/libxml2/trio.c:6397:22: note: expected 'va_list' but argument is of type 'void *'
6397 | TRIO_VA_LIST_PTR arglist,
| ^
external/libxml2/triodef.h:172:58: note: in definition of macro 'TRIO_ARGS6'
172 | # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6)
| ^~
external/libxml2/trio.c: In function 'trio_cscanfv':
external/libxml2/trio.c:6810:57: error: incompatible type for argument 5 of 'TrioScan'
6810 | return TrioScan(&data, 0, TrioInStreamCustom, format, NULL, args);
| ^~~~
| |
| void *
In file included from external/libxml2/trio.c:47:
external/libxml2/trio.c:6397:22: note: expected 'va_list' but argument is of type 'void *'
6397 | TRIO_VA_LIST_PTR arglist,
| ^
external/libxml2/triodef.h:172:58: note: in definition of macro 'TRIO_ARGS6'
172 | # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6)
| ^~
external/libxml2/trio.c: In function 'trio_sscanfv':
external/libxml2/trio.c:6864:13: error: incompatible type for argument 5 of 'TrioScan'
6864 | format, NULL, args);
| ^~~~
| |
| void *
In file included from external/libxml2/trio.c:47:
external/libxml2/trio.c:6397:22: note: expected 'va_list' but argument is of type 'void *'
6397 | TRIO_VA_LIST_PTR arglist,
| ^
external/libxml2/triodef.h:172:58: note: in definition of macro 'TRIO_ARGS6'
172 | # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6)
| ^~
......
scons: *** [build/external/debug_aarch/linux/3.10/64/x86/gcc/8.5/default/libxml2/trio.os] Error 1
scons: building terminated because of errors.
I am new one on ARM arch and cross-compilation but we need to migrate the rosetta to new cluster w/ aarch chips.
Can anyone help me with this issue? Thanks!
Category:
Post Situation:
Recent versions of Rosetta (the weekly releases, at least - perhaps not 3.13) should be set up to compile properly on the Apply M1 ARM-based Macs. I don't know how much change there is for that versus your particular aarch64 cluster. (Which specific machines is the cluster running?)
The specific errors that you're getting look to be related to the C/C++ standard library you're using. In particular, the `strcasecmp()` is a POSIX function. Throwing an error on that function indicates that you may not have full POSIX support on the platform you're compiling for. Do you know if that's the case? There might be compiler settings you may need to change.
The other errors are in the external libxml2 library. I don't have enough experience with that to say for certain, but you might be able to change source/external/libxml2/config.h to delete the line `#define VA_LIST_IS_ARRAY 1`. That may make those other issues go away. (It also may break things even further.)
Thank you very much!
According to the Rosetta release note, 3.13 has native support to Apple M1, but only 32 bit (following the official instruction) version 99% passed the unit tests. After hacking build/setup_platforms.py as following, the building step of 64bit version works perfectly and running rosetta_scripts.default.macosclangrelease will get an echo of blank RosettaScripts, but nearly 2/3 unit tests failed. That is quite a long story.
The aarch64 cluster is based on Hisilicon Kunpeng-920 w/ architecture ARM v8.2 and running CentOS 7.6. You may find more from links in the code box of the first post.
Yes I checked our public gcc w/ gcc -v command, it looks like POSIX is supported.
Because it is a warn instead of error, i just ignore the warning.
For the libxml2 error I modified the code following your kind instruction, the compilation was slowly running and died bcs libstdc++.so is incompatible for somehow.
In the other hand, I found a specific clang LLVM suite named "Bisheng" provided by the chip vendor for native compilation in aarch64.
I have to say this weird because the atomic lib is missing during every scons building. but when i run the command output by scons i works. acturally libatomic.so.1 is located in our public lib path /public/software/env01-arm64/lib/ and i have tried put that path into LD_LIBRARY_PATH or basic.settings but it doesnt work at all.
I'm not familiar w/ Scons but its so funny.
UPDATE:
this path issue is temporally solved by:
By default Scons ignores externally set environment variables. (This is an attempt to make the build process more reproducible.)
To adjust this, you'll need to edit the site.settings or user.settings files. I'd recommend taking a look at source/tools/build/site.settings By default the release version should copy over many of the important environment paths, but it may help to uncomment the `"ENV" : os.environ,` line. That might be my suggested first step to debug such "it works on the command line, but not when I run scons" issues.
Thanks a lot! it finally works!
It looks like rosetta is ready for aarch64!