zig icon indicating copy to clipboard operation
zig copied to clipboard

Zig cannot build packages with QEMU cpu emulation

Open tczaude opened this issue 2 years ago • 0 comments

Zig Version

zig-bin-0.9.1

Steps to Reproduce

Best on live example

>>> Emerging (1 of 2) sys-fs/ncdu-2.1::core-kit
 * Fetching files in the background.
 * To view fetch progress, run in another terminal:
 * tail -f /var/log/emerge-fetch.log
 * ncdu-2.1.tar.gz BLAKE2B SHA512 size ;-) ...                                                                                                                                                                                        [ ok ]
>>> Unpacking source...
>>> Unpacking ncdu-2.1.tar.gz to /var/tmp/portage/sys-fs/ncdu-2.1/work
>>> Source unpacked in /var/tmp/portage/sys-fs/ncdu-2.1/work
>>> Preparing source in /var/tmp/portage/sys-fs/ncdu-2.1/work/ncdu-2.1 ...
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/sys-fs/ncdu-2.1/work/ncdu-2.1 ...
>>> Source configured.
>>> Compiling source in /var/tmp/portage/sys-fs/ncdu-2.1/work/ncdu-2.1 ...
make -j1
zig build -Drelease-fast
error(compilation): clang failed with stderr: error: unknown target CPU 'pentium-m'
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, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, x86-64, x86-64-v2, x86-64-v3, x86-64-v4

./src/main.zig:13:11: error: C import failed
const c = @cImport(@cInclude("locale.h"));
          ^
ncdu...The following command exited with error code 1:
/opt/zig-bin-0.9.1/zig build-exe /var/tmp/portage/sys-fs/ncdu-2.1/work/ncdu-2.1/src/main.zig /var/tmp/portage/sys-fs/ncdu-2.1/work/ncdu-2.1/src/ncurses_refs.c -lc -lncursesw -OReleaseFast --cache-dir /var/tmp/portage/sys-fs/ncdu-2.1/work/ncdu-2.1/zig-cache --global-cache-dir /var/tmp/portage/sys-fs/ncdu-2.1/homedir/.cache/zig --name ncdu -I /usr/include/ncursesw -D _DEFAULT_SOURCE -D _XOPEN_SOURCE=600 --enable-cache
error: the following build command failed with exit code 1:
/var/tmp/portage/sys-fs/ncdu-2.1/work/ncdu-2.1/zig-cache/o/6e5d94ef3890ea346f6a4d9e442e7c9d/build /opt/zig-bin-0.9.1/zig /var/tmp/portage/sys-fs/ncdu-2.1/work/ncdu-2.1 /var/tmp/portage/sys-fs/ncdu-2.1/work/ncdu-2.1/zig-cache /var/tmp/portage/sys-fs/ncdu-2.1/homedir/.cache/zig -Drelease-fast
make: *** [Makefile:15: release] Error 1
 * ERROR: sys-fs/ncdu-2.1::core-kit failed (compile phase):
 *   emake failed
 *
 * If you need support, post the output of `emerge --info '=sys-fs/ncdu-2.1::core-kit'`,
 * the complete build log and the output of `emerge -pqv '=sys-fs/ncdu-2.1::core-kit'`.
 * The complete build log is located at '/var/tmp/portage/sys-fs/ncdu-2.1/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sys-fs/ncdu-2.1/temp/environment'.
 * Working directory: '/var/tmp/portage/sys-fs/ncdu-2.1/work/ncdu-2.1'
 * S: '/var/tmp/portage/sys-fs/ncdu-2.1/work/ncdu-2.1'

/proc/cpuinfo

processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 13
model name      : QEMU Virtual CPU version 2.5+
stepping        : 3
microcode       : 0x1
cpu MHz         : 0.000
cache size      : 16384 KB
physical id     : 0
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pse36 clflush mmx fxsr sse sse2 syscall nx lm rep_good nopl xtopology cpuid pni cx16 x2apic hypervisor lahf_lm pti
bugs            : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf
bogomips        : 4338.48
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

Expected Behavior

I was expecting to build ncdu package using qemu virtualization

Actual Behavior

Correct build without use extra options like -Dcpu=...

tczaude avatar Apr 05 '22 14:04 tczaude