ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
33.91k stars 2.48k forks source link

-entry does not suppress DllMainCRTStartup #11285

Open Hugne opened 2 years ago

Hugne commented 2 years ago

Zig Version

0.10.0-dev.1487+916a65cb7

Steps to Reproduce

//main.zig
export fn entry() void {}

zig.exe build-lib main.zig -target x86_64-windows -fno-stack-check -fPIC -fno-soname -fno-unwind-tables -dynamic -fsingle-threaded --entry entry

dumpbin.exe main.dll /EXPORTS
...
    ordinal hint RVA      name

          1    0 00001C90 _DllMainCRTStartup = _DllMainCRTStartup
          2    1 00001B60 entry = entry
...

Expected Behavior

The final DLL should only contain a single entry export, which is the DLL entrypoint.

Actual Behavior

DllMainCRTStartup is linked in from dllcrt2.obj and reexported in the final DLL.

Hugne commented 2 years ago

-fno-export-dll-fns works around this. But that cannot be set in build.zig, only passed as option to build-lib.