sonic
sonic copied to clipboard
Compile error on centos system
Does anyone develop native code on Centos?
My ENV: Intel Xeon, Centos 8, Python 3.9.0, clang version 13.0.0, get some compile error with the latest code:
(py39_env) [eric@icx250 sonic]$ make
mkdir -p internal/native/avx/
echo '// Code generated by Makefile, DO NOT EDIT.' > internal/native/avx/native_amd64.go
echo >> internal/native/avx/native_amd64.go
sed -e 's/{{PACKAGE}}/avx/g' internal/native/native_amd64.tmpl >> internal/native/avx/native_amd64.go
mkdir -p output/avx
clang -mno-red-zone -fno-asynchronous-unwind-tables -fno-builtin -fno-exceptions -fno-rtti -fno-stack-protector -nostdlib -O3 -Wall -Werror -Wno-misleading-indentation -Wno-incompatible-pointer-types -msse -mno-sse4 -mavx -mno-avx2 -DUSE_AVX=1 -DUSE_AVX2=0 -S -o output/avx/native.s native/native.c
python3 tools/asm2asm/asm2asm.py internal/native/avx/native_amd64.s output/avx/native.s
Traceback (most recent call last):
File "/home/download/sonic_dir/sonic/tools/asm2asm/asm2asm.py", line 2132, in
Is this a config problem, or the asm2asm.py just only support the assembly code compile from Mac OS?
do you change native C code?
I want to do some work on native code, but I can't compile successful before I do any change.
Just modify the Makefile for some compile errors: (base) [eric@icx250 sonic]$ git diff Makefile diff --git a/Makefile b/Makefile index afe1b30..20192de 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ CC_amd64 := clang ASM2ASM_amd64 := tools/asm2asm/asm2asm.py
CFLAGS := -mno-red-zone -CFLAGS += -arch x86_64 +#CFLAGS += -arch x86_64 CFLAGS += -fno-asynchronous-unwind-tables CFLAGS += -fno-builtin CFLAGS += -fno-exceptions @@ -43,7 +43,7 @@ CFLAGS += -fno-rtti CFLAGS += -fno-stack-protector CFLAGS += -nostdlib CFLAGS += -O3 -CFLAGS += -Wall -Werror +CFLAGS += -Wall -Werror -Wno-misleading-indentation -Wno-incompatible-pointer-types
DONOT change any flags. At present, asm2asm only supports very limited ASM syntax, not including GOT、.text instruction ... etc —— In one word, you can only use it to write simple C functions, without gcc libs
(base) [eric@icx250 sonic]$ make mkdir -p internal/native/avx/ echo '// Code generated by Makefile, DO NOT EDIT.' > internal/native/avx/native_amd64.go echo >> internal/native/avx/native_amd64.go sed -e 's/{{PACKAGE}}/avx/g' internal/native/native_amd64.tmpl >> internal/native/avx/native_amd64.go mkdir -p output/avx clang -mno-red-zone -arch x86_64 -fno-asynchronous-unwind-tables -fno-builtin -fno-exceptions -fno-rtti -fno-stack-protector -nostdlib -O3 -Wall -Werror -msse -mno-sse4 -mavx -mno-avx2 -DUSE_AVX=1 -DUSE_AVX2=0 -S -o output/avx/native.s native/native.c clang-13: error: argument unused during compilation: '-arch x86_64' [-Werror,-Wunused-command-line-argument] make: *** [Makefile:107: internal/native/avx/native_amd64.s] Error 1
Do not change any word, get this error. You do not have a Linux PC, and have a try?
only use it on macOS and clang 12+
Seems that this is because you have changed the makefile:
clang-13: error: argument unused during compilation: '-arch x86_64' [-Werror,-Wunused-command-line-argument]
only use it on macOS and clang 12+
As a open source project, you'd better clarify this limitation in the readme. Do you have the plans to support Linux OS recently?
This is only used for our development, not for sonic's users. If you want to use asm2asm to develop your own code, you can submit issues on its repo. If you want develop sonic, you can contact us about your plan and we will see how it works
I want to modify the native code with AVX512 and check the performance.
Actually our team has tried this and it decreased the speed due to the CPU underclocking effects introduced by AVX512. You can just try it in C-code benchmark (like Google Test, etc.)
Which CPU platform did you test on?
As I know, on the latest Intel platform, Icelake or SPR, the problem of underclocking has been solved. Could you upload the AVX512 code as a branch, I can do some tests on these platform to evaluate this problem.
cc @PureWhiteWu @liuq19 @chenzhuoyu , any code left?
only use it on macOS and clang 12+
As a open source project, you'd better clarify this limitation in the readme. Do you have the plans to support Linux OS recently?
checkout this repo should be compile with clang on linux(arch).But asm2asm need further work
only use it on macOS and clang 12+
As a open source project, you'd better clarify this limitation in the readme. Do you have the plans to support Linux OS recently?
checkout this repo should be compile with clang on linux(arch).But asm2asm need further work
yeah, asm2asm does not works in Linux because of different asm syntax.
only use it on macOS and clang 12+
As a open source project, you'd better clarify this limitation in the readme. Do you have the plans to support Linux OS recently?
checkout this repo should be compile with clang on linux(arch).But asm2asm need further work
yeah, asm2asm does not works in Linux because of different asm syntax.
yep, I believe if we want sonic running on ARM we should spill the work to two-step.
- adaptation Sonic native code from Apple Clang to LLVM Clang(now we can compile with LLVM clang, But asm2asm needs further work)
- adaptations native code from AVX to NEON(adaptations ARM instruction set) All work needs to contribute asm2asm project, I'm working learn ATT assembly to plan9, but only a few documents of plan9 can be found. it maybe takes looong time.
only use it on macOS and clang 12+
As a open source project, you'd better clarify this limitation in the readme. Do you have the plans to support Linux OS recently?
checkout this repo should be compile with clang on linux(arch).But asm2asm need further work
yeah, asm2asm does not works in Linux because of different asm syntax.
Any plan to support Linux?
Perhaps using -ffreestanding and small reimplementation of STDC like eg. string.h would not work on freestanding?
Example
> clang -mno-red-zone -target x86_64-apple-macos11 -fno-asynchronous-unwind-tables -fno-builtin -fno-exceptions -fno-rtti -fno-stack-protector -nostdlib -O3 -Wall -Werror -msse -mno-sse4-mavx -mpclmul -mno-avx2 -DUSE_AVX=1 -DUSE_AVX2=0 -S -ffreestanding -o out_avx.s a.c
> cat out_avx.s
.section __TEXT,__text,regular,pure_instructions
.build_version macos, 11, 0
.globl _go_reflect_tree ## -- Begin function go_reflect_tree
.p2align 4, 0x90
_go_reflect_tree: ## @go_reflect_tree
## %bb.0:
pushq %rbp
movq %rsp, %rbp
xorl %eax, %eax
cmpq $1, %rdi
sbbl %eax, %eax
orl $65535, %eax ## imm = 0xFFFF
popq %rbp
retq
## -- End function
.subsections_via_symbols
> cat a.c
#include <stdint.h>
#include <immintrin.h>
//#include <string.h>
int go_reflect_tree(void* ptr)
{
register int a = 0;
if (ptr == 0) return -1;
if ((uintptr_t)ptr & 0xff) a = 0xff;
a |= 0xffff;
return a;
}