Skip to content

build runner no longer supports -fsingle-threaded #24723

@andrewrk

Description

@andrewrk

After #24588, trying to use zig build on single-threaded systems causes something like this:

[18/19] Linking CXX executable zig2
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: warning: /boot/system/develop/lib/crtn.o: missing .note.GNU-stack section implies executable stack
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/13.3.0/../../../../x86_64-unknown-haiku/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
[19/19] Building stage3
FAILED: [code=2] stage3/bin/zig /boot/home/proj/zig/build/stage3/bin/zig 
cd /boot/home/proj/zig && /boot/home/proj/zig/build/zig2 build --prefix /boot/home/proj/zig/build/stage3 --zig-lib-dir /boot/home/proj/zig/lib -Dversion-string=0.15.0-dev.1428+e17a050bc -Dtarget=native -Dcpu=native -Denable-llvm -Dconfig_h=/boot/home/proj/zig/build/config.h -Dno-langref -Doptimize=Debug
lib/std/Thread.zig:440:9: error: Cannot spawn thread when building in single-threaded mode
        @compileError("Cannot spawn thread when building in single-threaded mode");
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
    start: lib/std/Build/WebServer.zig:167:39
    main: lib/compiler/build_runner.zig:465:17
    4 reference(s) hidden; use '-freference-trace=6' to see all references
lib/std/Thread.zig:440:9: error: Cannot spawn thread when building in single-threaded mode
        @compileError("Cannot spawn thread when building in single-threaded mode");
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.

The answer is in the reference trace: it's trying to spawn a thread for the web ui without checking whether the host is capable of spawning threads.

Metadata

Metadata

Assignees

Labels

bugObserved behavior contradicts documented or intended behaviorcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.regressionIt worked in a previous version of Zig, but stopped working.zig build systemstd.Build, the build runner, `zig build` subcommand, package management

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions