Skip to content

"Illegal instruction" error after compiling oksh with zig cc and --no-thanks flag #76

@absolutelynothinghere

Description

@absolutelynothinghere

I compiled oksh using the Zig CC compiler (clang wrapper with cross-compilation support and ubsan) once with the --no-thanks flag and once without. The binary compiled with --no-thanks causes an "Illegal instruction" error when attempting to compile other programs, meaning that undefined behavior was detected.

Here's an example:

mkdir -p /tmp/test && cd /tmp/test
wget https://github.com/ibara/oksh/releases/download/oksh-7.3/oksh-7.3.tar.gz
wget https://invisible-island.net/archives/byacc/byacc-20230521.tgz

# compile oksh with `--no-thanks` using zig cc
tar xf oksh-7.3.tar.gz && cd oksh-7.3
CC="zig cc -target x86_64-linux-musl" ./configure --no-thanks
make

# configure byacc using oksh as shell
cd /tmp/test
tar xf byacc-20230521.tgz && cd byacc-20230521
sed -i -e 's_/bin/sh_/tmp/test/oksh-7.3/oksh_' configure
./configure --help # Illegal instruction

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions