nob.h icon indicating copy to clipboard operation
nob.h copied to clipboard

gcc ld invalid argument error, when appending "" to cmd

Open whophi opened this issue 3 months ago • 1 comments

System:

  • Windows 11 (10.0-26100)
  • MINGW64_NT-10.0-26100 version 3.6.4-23a25d49.x86_64 (runneradmin@runnervm51nrn) (gcc version 15.1.0 (GCC) )
  • Nob.h - v1.23.0

Minimal example:

// File: nob_test.c
#define NOB_IMPLEMENTATION
#include "nob.h"
int main(int argc, char** argv)
{
  NOB_GO_REBUILD_URSELF(argc, argv);
  Nob_Cmd cmd = {0};
  nob_cmd_append(&cmd, "gcc", "-o", "bug_test", __FILE__, ""); // No error, when removing the "" here
  if (!nob_cmd_run(&cmd)) return 1;
  return 0;
}
gcc -o nob_test nob_test.c
./nob_test.exe

Output:

[INFO] CMD: gcc -o bug_test ./nob_test.c 
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find : Invalid argument
collect2.exe: error: ld returned 1 exit status
[ERROR] command exited with exit code 1

This is useful for macros, e.g.:

# define ASSERT_ENABLE ""
# define ASSERT_DISABLE "-DNDEBUG"

NOTE: This worked in v1.20.2, using the old api (nob_cmd_run_sync_and_reset)

whophi avatar Sep 05 '25 15:09 whophi

I fixed it in this PR Let us wait Mr T merge it in.

fbucafusco avatar Sep 06 '25 22:09 fbucafusco