Skip to content

zig cc -E -dM with -target argument should not produce an output file #20739

Closed

Description

@zhylmzr

Zig Version

0.14.0-dev.494+1fc42ed3e

Steps to Reproduce and Observed Behavior

clang -target x86_64-macos -E -dM main.c // no main.o
zig cc -target x86_64-macos -E -dM main.c // emit main.o

Related (golang)

When trying CGO cross-platform compilation, CGO will first obtain the macro definition of the compiler. However, for unknown reasons, cwd will be modified during CGO processing, causing the working directory to be in a read-only directory. At this time, generating files will fail.

cgo output with zig log
WORK=/tmp/go-build1020796300
mkdir -p $WORK/b042/
cd /usr/local/go/src/runtime/cgo
TERM='dumb' CGO_LDFLAGS='"-O2" "-g" "-lpthread"' /usr/local/go/pkg/tool/linux_amd64/cgo -objdir $WORK/b042/ -importpath runtime/cgo -import_runtime_cgo=false -import_syscall=false -exportheader=$WORK/b042/_cgo_install.h -- -I $WORK/b042/ -O2 -g -Wall -Werror -fno-stack-protector ./cgo.go
# runtime/cgo
args: /home/zhylmzr/proj/zig/build/stage3/bin/zig
args: cc
args: -target
args: x86_64-macos
args: -E
args: -dM
args: -arch
args: x86_64
args: -m64
args: -I
args: $WORK/b042/
args: -O2
args: -Wall
args: -Werror
args: -fno-stack-protector
args: -I
args: .
args: /tmp/cgo-gcc-input-1407526148.c
create error
error: unable to create compilation: AccessDenied

#20689

Expected Behavior

-E -dM will not emit an bin file, regardless of whether there is a -target parameter

Activity

  1. added
    bug
    on Jul 22, 2024
  2. Vexu commented on Jul 22, 2024

    @Vexu
    Member

    Duplicate of #20359

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions