Repository navigation
Description
Zig Version
0.15-dev
Steps to Reproduce and Observed Behavior
git clone https://github.com/libjxl/libjxl
cd libjxl
./deps.sh
export CC="zig cc -target native-native-gnu"
export CXX="zig c++ -target native-native-gnu"
mkdir build && cd build
cmake -B build
cd build
make -j->
*** Waiting for unfinished jobs....
info: available CPUs for architecture 'x86_64':
alderlake
amdfam10
arrowlake
arrowlake_s
athlon
athlon64
athlon64_sse3
athlon_4
athlon_fx
athlon_mp
athlon_tbird
athlon_xp
atom
atom_sse4_2_movbe
barcelona
bdver1
bdver2
bdver3
bdver4
bonnell
broadwell
btver1
btver2
c3
c3_2
cannonlake
cascadelake
clearwaterforest
cooperlake
core2
corei7
diamondrapids
emeraldrapids
generic
geode
goldmont
goldmont_plus
gracemont
grandridge
graniterapids
graniterapids_d
haswell
i386
i486
i586
i686
icelake_client
icelake_server
ivybridge
k6
k6_2
k6_3
k8
k8_sse3
knl
knm
lakemont
lunarlake
meteorlake
nehalem
nocona
opteron
opteron_sse3
pantherlake
penryn
pentium
pentium2
pentium3
pentium3m
pentium4
pentium_m
pentium_mmx
pentiumpro
prescott
raptorlake
rocketlake
sandybridge
sapphirerapids
sierraforest
silvermont
skx
skylake
skylake_avx512
slm
tigerlake
tremont
westmere
winchip2
winchip_c6
x86_64
x86_64_v2
x86_64_v3
x86_64_v4
yonah
znver1
znver2
znver3
znver4
znver5
error: unknown CPU: 'x86'Which makes perfect sense, given that:
[m@M-TH libjxl]$ grep -r "\-march" .
./third_party/skcms/ninja/clang.native:target_flags = -march=native
./third_party/skcms/ninja/gcc.native:target_flags = -march=native
./third_party/skcms/ninja/clang.hsw:target_flags = -march=x86-64 -mavx2 -mf16c
./third_party/skcms/ninja/common: -march=x86-64 -mavx2 -mf16c -MD -MF $out.d -c $in -o $out
./third_party/skcms/ninja/common: -march=x86-64 -mavx512f -mavx512dq -mavx512cd -mavx512bw -mavx512vl $
So we create a zig-cc wrapper script that replaces -march=X-Y with -march=X_Y and run again:
export CC=zig-cc
export CXX=zig-c++
cmake -B build
make->
[ 48%] Building CXX object lib/CMakeFiles/jxl_dec-obj.dir/jxl/modular/transform/squeeze_params.cc.o
In file included from /home/m/static-php-cli/source/libjxl/third_party/skcms/src/skcms_TransformSkx.cc:53:
/home/m/static-php-cli/source/libjxl/third_party/skcms/src/Transform_inl.h:833:9: error: AVX vector return of type 'F' (aka 'Vec<16, float>') without 'evex512' enabled changes the ABI
833 | a = F_from_U8(load<U8>(src + 1*i));
| ^
/home/m/static-php-cli/source/libjxl/third_party/skcms/src/Transform_inl.h:589:12: error: AVX vector return of type 'float __attribute__((ext_vector_type(16)))' (vector of 16 'float' values) without 'evex512' enabled changes
the ABI
589 | return cast<F>(v) * (1/255.0f);
| ^
/home/m/static-php-cli/source/libjxl/third_party/skcms/src/Transform_inl.h:837:17: error: AVX vector return of type 'F' (aka 'Vec<16, float>') without 'evex512' enabled changes the ABI
837 | r = g = b = F_from_U8(load<U8>(src + 1*i));
| ^
...It seems that AVX512 and more feature checks succeed, despite them not being available for the -target and -march. -mavx512f being passed after -march doesn't fix it. Setting -march=x86_64 in CFLAGS should not even succeed with the feature check, but it still does.
So I tried manually checking for these features and found some interesting results:
clang -march=x86-64 -mavx512f -E - <<<"__EVEX512__" -> 1 (makes sense)
zig cc -target x86_64-linux-gnu -march=x86-64 -mavx512f -E - <<<"__EVEX512__" -> 1 (makes sense)
zig cc -target native-linux-gnu -march=x86-64 -mavx512f -E - <<<"__EVEX512__"`
zig: error: unsupported option '-march=' for target 'native-linux-gnu'
zig: error: unsupported option '-mavx512f' for target 'native-linux-gnu'Which is also understandable. But now it gets interesting:
[m@M-TH CMakeFiles]$ zig cc -target x86_64-linux-gnu -march=x86_64 -mavx512f -E - <<<"__EVEX512__"
error: unknown target CPU 'x86_64'
note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake
-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, raptorlake, meteorlake, arrowlake, arrowlake-s, lunarlake, gracemont, pantherlake, sierraforest, grandridge, gran
iterapids, graniterapids-d, emeraldrapids, clearwaterforest, diamondrapids, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, znver4, znver5, x86-64, x86-64-v2, x86-64-v3, x86-64-v4So we need x86-64 here, not x86_64.
[m@M-TH CMakeFiles]$ zig cc -target x86_64-linux-gnu -march=x86-64 -mavx512f -E - <<<"__EVEX512__"
# 1 "<stdin>"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 423 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "<stdin>" 2
1
[m@M-TH CMakeFiles]$ zig cc -target x86_64-linux-gnu -march=x86-64 -mavx512f test.c
info: available CPUs for architecture 'x86_64':
...
error: unknown CPU: 'x86'So here we need to use x86_64, right.
[m@M-TH CMakeFiles]$ zig cc -target x86_64-linux-gnu -march=x86_64 -mavx512f test.c
LLVM ERROR: Cannot select: 0x7f4058c3b110: v4i1 = setcc 0x7f4059496200, 0x7f40594959b0, setgt:ch, comparef.zig:123:5 @[ unordsf2.zig:15:29 ]
0x7f4059496200: v4i32 = and 0x7f4059495780, 0x7f4059d54440, comparef.zig:121:5 @[ unordsf2.zig:15:29 ]
0x7f4059495780: v4i32 = bitcast 0x7f4058c3b0a0, comparef.zig:121:5 @[ unordsf2.zig:15:29 ]
0x7f4058c3b0a0: v4f32 = X86ISD::INSERTPS 0x7f4059d67110, 0x7f4059d67880, TargetConstant:i8<28>, comparef.zig:121:5 @[ unordsf2.zig:15:29 ]
0x7f4059d67110: v4f32 = scalar_to_vector 0x7f4059d64460, comparef.zig:121:5 @[ unordsf2.zig:15:29 ]
0x7f4059d64460: f32,ch = CopyFromReg 0x7f405a28abb8, Register:f32 %1
0x7f4059d640e0: f32 = Register %1
0x7f4059d67880: v4f32 = scalar_to_vector 0x7f4059d53e20, comparef.zig:121:5 @[ unordsf2.zig:15:29 ]
0x7f4059d53e20: f32,ch = CopyFromReg 0x7f405a28abb8, Register:f32 %0
0x7f4058c3aee0: f32 = Register %0
0x7f4059d66f50: i8 = TargetConstant<28>
0x7f4059d54440: v4i32,ch = X86ISD::VBROADCAST_LOAD<(load (s32) from constant-pool)> 0x7f405a28abb8, 0x7f4059495e10, comparef.zig:121:5 @[ unordsf2.zig:15:29 ]
0x7f4059495e10: i64 = X86ISD::WrapperRIP TargetConstantPool:i64<float 0x7FFFFFFFE0000000> 0
0x7f4059d53800: i64 = TargetConstantPool<float 0x7FFFFFFFE0000000> 0
0x7f40594959b0: v4i32,ch = X86ISD::VBROADCAST_LOAD<(load (s32) from constant-pool)> 0x7f405a28abb8, 0x7f4059d67730, comparef.zig:123:5 @[ unordsf2.zig:15:29 ]
0x7f4059d67730: i64 = X86ISD::WrapperRIP TargetConstantPool:i64<i32 2139095040> 0
0x7f4059d67180: i64 = TargetConstantPool<i32 2139095040> 0
In function: __unordsf2
Aborted (core dumped)
And when we use zig c++ instead of zig cc:
[m@M-TH build]$ zig c++ -fPIC -Os -mavx512f test.cxx
fatal error: error in backend: Cannot select: 0x7fbb19ed5880: v4i1 = setcc 0x7fbb19ed5730, 0x7fbb19ed5b90, setule:ch
0x7fbb19ed5730: v4i64 = or disjoint 0x7fbb19ed56c0, 0x7fbb19ed8e70
0x7fbb19ed56c0: v4i64 = X86ISD::VBROADCAST 0x7fbb19ed5180
0x7fbb19ed5180: i64,ch = CopyFromReg 0x7fbb19ab7488, Register:i64 %6
0x7fbb19ed5650: i64 = Register %6
0x7fbb19ed8e70: v4i64,ch = load<(load (s256) from constant-pool)> 0x7fbb19ab7488, 0x7fbb19ed5c70, undef:i64
0x7fbb19ed5c70: i64 = X86ISD::WrapperRIP TargetConstantPool:i64<<4 x i64> <i64 0, i64 1, i64 2, i64 3>> 0
0x7fbb19ed4fc0: i64 = TargetConstantPool<<4 x i64> <i64 0, i64 1, i64 2, i64 3>> 0
0x7fbb19ed5030: i64 = undef
0x7fbb19ed5b90: v4i64,ch = CopyFromReg 0x7fbb19ab7488, Register:v4i64 %5
0x7fbb19ed57a0: v4i64 = Register %5
In function: _ZNSt3__16gslice6__initEm
zig: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 20.1.2 (https://github.com/ziglang/zig-bootstrap de424301411b3a34a8a908d8dca01a1d29f2c6df)
Target: x86_64-unknown-linux5.10.0-gnu2.39.0
Thread model: posix
InstalledDir: /home/m/static-php-cli/pkgroot/zig-x86_64-linux
zig: note: diagnostic msg:
********************
ββ [1/1] Linking
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
zig: note: diagnostic msg: /tmp/valarray-ab9204.cpp
zig: note: diagnostic msg: /tmp/valarray-ab9204.sh
zig: note: diagnostic msg:
ββ random_shuffle.cpp
********************
[m@M-TH build]$ fatal error: error in backend: Cannot select: 0x7f52107920d0: ch = masked_store<(store unknown-size into %ir.58, align 4, !tbaa !20)> 0x7f52105aac48, 0x7f5210794490, 0x7f5210793a10, undef:i64, 0x7f5210793f50
0x7f5210794490: v8i32,ch = CopyFromReg 0x7f52105aac48, Register:v8i32 %11
0x7f52107941f0: v8i32 = Register %11
0x7f5210793a10: i64 = add 0x7f5210794180, 0x7f5210793d20
0x7f5210794180: i64,ch = CopyFromReg 0x7f52105aac48, Register:i64 %7
0x7f5210794880: i64 = Register %7
0x7f5210793d20: i64 = shl 0x7f5210793d90, Constant:i8<2>
0x7f5210793d90: i64,ch = CopyFromReg 0x7f52105aac48, Register:i64 %12
0x7f5210792220: i64 = Register %12
0x7f5210791d50: i8 = Constant<2>
0x7f52107918f0: i64 = undef
0x7f5210793f50: v8i1 = or 0x7f52107947a0, 0x7f52107942d0
0x7f52107947a0: v8i1 = extract_subvector 0x7f5210791f10, Constant:i64<0>
0x7f5210791f10: v16i1 = insert_subvector 0x7f52107917a0, 0x7f52107916c0, Constant:i64<0>
0x7f52107917a0: v16i1 = BUILD_VECTOR Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>
0x7f5210793ee0: i8 = Constant<0>
0x7f5210793ee0: i8 = Constant<0>
0x7f5210793ee0: i8 = Constant<0>
0x7f5210793ee0: i8 = Constant<0>
0x7f5210793ee0: i8 = Constant<0>
0x7f5210793ee0: i8 = Constant<0>
0x7f5210793ee0: i8 = Constant<0>
0x7f5210793ee0: i8 = Constant<0>
0x7f5210793ee0: i8 = Constant<0>
0x7f5210793ee0: i8 = Constant<0>
0x7f5210793ee0: i8 = Constant<0>
0x7f5210793ee0: i8 = Constant<0>
0x7f5210793ee0: i8 = Constant<0>
0x7f5210793ee0: i8 = Constant<0>
0x7f5210793ee0: i8 = Constant<0>
0x7f5210793ee0: i8 = Constant<0>
0x7f52107916c0: v4i1 = setcc 0x7f5210793a80, 0x7f5210794500, setule:ch
0x7f5210793a80: v4i64 = or disjoint 0x7f5210794650, 0x7f5210793af0
0x7f5210794650: v4i64 = X86ISD::VBROADCAST 0x7f5210793d90
0x7f5210793d90: i64,ch = CopyFromReg 0x7f52105aac48, Register:i64 %12
0x7f5210792220: i64 = Register %12
0x7f5210793af0: v4i64,ch = load<(load (s256) from constant-pool)> 0x7f52105aac48, 0x7f5210791810, undef:i64
0x7f5210791810: i64 = X86ISD::WrapperRIP TargetConstantPool:i64<<4 x i64> <i64 0, i64 1, i64 2, i64 3>> 0
0x7f5210791b20: i64 = TargetConstantPool<<4 x i64> <i64 0, i64 1, i64 2, i64 3>> 0
0x7f52107918f0: i64 = undef
0x7f5210794500: v4i64,ch = CopyFromReg 0x7f52105aac48, Register:v4i64 %9
0x7f5210791ce0: v4i64 = Register %9
0x7f5210792300: i64 = Constant<0>
0x7f5210792300: i64 = Constant<0>
0x7f52107942d0: v8i1 = extract_subvector 0x7f52107915e0, Constant:i64<0>
0x7f52107915e0: v16i1 = X86ISD::KSHIFTL 0x7f5210792450, TargetConstant:i8<4>
0x7f5210792450: v16i1 = insert_subvector undef:v16i1, 0x7f5210794570, Constant:i64<0>
0x7f5210794960: v16i1 = undef
0x7f5210794570: v4i1 = setcc 0x7f5210793cb0, 0x7f5210791ea0, setule:ch
0x7f5210793cb0: v4i64 = or disjoint 0x7f5210794650, 0x7f5210791a40
0x7f5210794650: v4i64 = X86ISD::VBROADCAST 0x7f5210793d90
0x7f5210793d90: i64,ch = CopyFromReg 0x7f52105aac48, Register:i64 %12
0x7f5210792220: i64 = Register %12
0x7f5210791a40: v4i64,ch = load<(load (s256) from constant-pool)> 0x7f52105aac48, 0x7f5210793c40, undef:i64
0x7f5210793c40: i64 = X86ISD::WrapperRIP TargetConstantPool:i64<<4 x i64> <i64 4, i64 5, i64 6, i64 7>> 0
0x7f5210791b90: i64 = TargetConstantPool<<4 x i64> <i64 4, i64 5, i64 6, i64 7>> 0
0x7f52107918f0: i64 = undef
0x7f5210791ea0: v4i64,ch = CopyFromReg 0x7f5210794500:1, Register:v4i64 %10
0x7f52107946c0: v4i64 = Register %10
0x7f5210792300: i64 = Constant<0>
0x7f52107940a0: i8 = TargetConstant<4>
0x7f5210792300: i64 = Constant<0>
In function: _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6insertEmmw
zig: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 20.1.2 (https://github.com/ziglang/zig-bootstrap de424301411b3a34a8a908d8dca01a1d29f2c6df)
Target: x86_64-unknown-linux5.10.0-gnu2.39.0
Thread model: posix
InstalledDir: /home/m/static-php-cli/pkgroot/zig-x86_64-linux
zig: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
zig: note: diagnostic msg: /tmp/string-dc991d.cpp
zig: note: diagnostic msg: /tmp/string-dc991d.sh
zig: note: diagnostic msg:
********************
fatal error: error in backend: Cannot select: 0x7f0d00840830: ch = masked_store<(store unknown-size into %ir.36, align 4, !tbaa !11)> 0x7f0d0069cc48, 0x7f0d007ede80, 0x7f0d007edbe0, undef:i64, 0x7f0d0074fe10
0x7f0d007ede80: v8i32,ch = CopyFromReg 0x7f0d0069cc48, Register:v8i32 %6
0x7f0d007e3a10: v8i32 = Register %6
0x7f0d007edbe0: i64 = add 0x7f0d00750190, 0x7f0d007ee190
0x7f0d00750190: i64,ch = CopyFromReg 0x7f0d0069cc48, Register:i64 %2
0x7f0d00840ad0: i64 = Register %2
0x7f0d007ee190: i64 = shl 0x7f0d00840d70, Constant:i8<2>
0x7f0d00840d70: i64,ch = CopyFromReg 0x7f0d0069cc48, Register:i64 %7
0x7f0d0074fef0: i64 = Register %7
0x7f0d00840de0: i8 = Constant<2>
0x7f0d007ee120: i64 = undef
0x7f0d0074fe10: v8i1 = or 0x7f0d007e3540, 0x7f0d007ee430
0x7f0d007e3540: v8i1 = extract_subvector 0x7f0d007e3e00, Constant:i64<0>
0x7f0d007e3e00: v16i1 = insert_subvector 0x7f0d007e3d90, 0x7f0d0074fda0, Constant:i64<0>
0x7f0d007e3d90: v16i1 = BUILD_VECTOR Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>, Constant:i8<0>
0x7f0d007e3770: i8 = Constant<0>
0x7f0d007e3770: i8 = Constant<0>
0x7f0d007e3770: i8 = Constant<0>
0x7f0d007e3770: i8 = Constant<0>
0x7f0d007e3770: i8 = Constant<0>
0x7f0d007e3770: i8 = Constant<0>
0x7f0d007e3770: i8 = Constant<0>
0x7f0d007e3770: i8 = Constant<0>
0x7f0d007e3770: i8 = Constant<0>
0x7f0d007e3770: i8 = Constant<0>
0x7f0d007e3770: i8 = Constant<0>
0x7f0d007e3770: i8 = Constant<0>
0x7f0d007e3770: i8 = Constant<0>
0x7f0d007e3770: i8 = Constant<0>
0x7f0d007e3770: i8 = Constant<0>
0x7f0d007e3770: i8 = Constant<0>
0x7f0d0074fda0: v4i1 = setcc 0x7f0d007e3930, 0x7f0d007e38c0, setule:ch
0x7f0d007e3930: v4i64 = or disjoint 0x7f0d00840f30, 0x7f0d007e3cb0
0x7f0d00840f30: v4i64 = X86ISD::VBROADCAST 0x7f0d00840d70
0x7f0d00840d70: i64,ch = CopyFromReg 0x7f0d0069cc48, Register:i64 %7
0x7f0d0074fef0: i64 = Register %7
0x7f0d007e3cb0: v4i64,ch = load<(load (s256) from constant-pool)> 0x7f0d0069cc48, 0x7f0d007e37e0, undef:i64
0x7f0d007e37e0: i64 = X86ISD::WrapperRIP TargetConstantPool:i64<<4 x i64> <i64 0, i64 1, i64 2, i64 3>> 0
0x7f0d007ed940: i64 = TargetConstantPool<<4 x i64> <i64 0, i64 1, i64 2, i64 3>> 0
0x7f0d007ee120: i64 = undef
0x7f0d007e38c0: v4i64,ch = CopyFromReg 0x7f0d0069cc48, Register:v4i64 %4
0x7f0d00840520: v4i64 = Register %4
0x7f0d00840c20: i64 = Constant<0>
0x7f0d00840c20: i64 = Constant<0>
0x7f0d007ee430: v8i1 = extract_subvector 0x7f0d007e3a80, Constant:i64<0>
0x7f0d007e3a80: v16i1 = X86ISD::KSHIFTL 0x7f0d007ede10, TargetConstant:i8<4>
0x7f0d007ede10: v16i1 = insert_subvector undef:v16i1, 0x7f0d007ee580, Constant:i64<0>
0x7f0d00840210: v16i1 = undef
0x7f0d007ee580: v4i1 = setcc 0x7f0d007e4180, 0x7f0d007ee4a0, setule:ch
0x7f0d007e4180: v4i64 = or disjoint 0x7f0d00840f30, 0x7f0d00840750
0x7f0d00840f30: v4i64 = X86ISD::VBROADCAST 0x7f0d00840d70
0x7f0d00840d70: i64,ch = CopyFromReg 0x7f0d0069cc48, Register:i64 %7
0x7f0d0074fef0: i64 = Register %7
0x7f0d00840750: v4i64,ch = load<(load (s256) from constant-pool)> 0x7f0d0069cc48, 0x7f0d0074ffd0, undef:i64
0x7f0d0074ffd0: i64 = X86ISD::WrapperRIP TargetConstantPool:i64<<4 x i64> <i64 4, i64 5, i64 6, i64 7>> 0
0x7f0d0074fcc0: i64 = TargetConstantPool<<4 x i64> <i64 4, i64 5, i64 6, i64 7>> 0
0x7f0d007ee120: i64 = undef
0x7f0d007ee4a0: v4i64,ch = CopyFromReg 0x7f0d007e38c0:1, Register:v4i64 %5
0x7f0d007e32a0: v4i64 = Register %5
0x7f0d00840c20: i64 = Constant<0>
0x7f0d007e3380: i8 = TargetConstant<4>
0x7f0d00840c20: i64 = Constant<0>
In function: _ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEEC2B8ne200100Emw
zig: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 20.1.2 (https://github.com/ziglang/zig-bootstrap de424301411b3a34a8a908d8dca01a1d29f2c6df)
Target: x86_64-unknown-linux5.10.0-gnu2.39.0
Thread model: posix
InstalledDir: /home/m/static-php-cli/pkgroot/zig-x86_64-linux
zig: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
zig: note: diagnostic msg: /tmp/locale-242faf.cpp
zig: note: diagnostic msg: /tmp/locale-242faf.sh
zig: note: diagnostic msg:
********************
Expected Behavior
Builds without issues, like Clang and GCC do. I've tried for hours with different CFLAGS options, stripping -march args and more. No luck.
Activity