pret / agbcc

C compiler
104 stars 75 forks source link

Build script fails on NixOS #62

Open inkstray opened 1 year ago

inkstray commented 1 year ago

I don't have very much knowledge on topic of coding and such... so I'll post my log in hopes that I will receive some support in some way.

gcc -MT toplev.o -MMD -MP -MF .d/toplev.Td -g -std=gnu11 -Werror-implicit-function-declaration -DOLD_COMPILER  -I. -I. -c toplev.c
toplev.c: In function ‘fatal_insn’:
toplev.c:1049:5: error: format not a string literal and no format arguments [-Werror=format-security]
 1049 |     error(message);
      |     ^~~~~
toplev.c: In function ‘v_message_with_decl’:
toplev.c:1235:26: warning: ‘%ld’ directive writing between 1 and 20 bytes into a region of size 5 [-Wformat-overflow=]
 1235 |         sprintf(fmt, "%%.%lds", width);
      |                          ^~~
toplev.c:1235:22: note: directive argument in the range [-9223372036854775808, 255]
 1235 |         sprintf(fmt, "%%.%lds", width);
      |                      ^~~~~~~~~
In file included from /nix/store/07kmxfmj8i8h76zzz9vw9zfvxsarqr5d-glibc-2.34-210-dev/include/stdio.h:888,
                 from thumb.h:1078,
                 from telf.h:25,
                 from config.h:12,
                 from toplev.c:26:
/nix/store/07kmxfmj8i8h76zzz9vw9zfvxsarqr5d-glibc-2.34-210-dev/include/bits/stdio2.h:38:10: note: ‘__builtin___sprintf_chk’ output between 5 and 24 bytes into a destination of size 7
   38 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   39 |                                   __glibc_objsize (__s), __fmt,
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   40 |                                   __va_arg_pack ());
      |                                   ~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make: *** [Makefile:81: toplev.o] Error 1
make: Leaving directory '/home/tryzen/Code/agbcc/gcc'
mid-kid commented 1 year ago

cc1: some warnings being treated as errors

Distributions enable -Werror by default now?? I didn't even know that was possible, it should be illegal. That will break a bunch more than this project.

As for fixing this, I guess this is using printf without a constant format string somewhere. We could fix that, or add -Wno-error somewhere in CFLAGS...

rawr51919 commented 1 year ago

cc1: some warnings being treated as errors

Distributions enable -Werror by default now?? I didn't even know that was possible, it should be illegal. That will break a bunch more than this project.

As for fixing this, I guess this is using printf without a constant format string somewhere. We could fix that, or add -Wno-error somewhere in CFLAGS...

If the changes from PR #59 were used this should make NixOS successfully compile agbcc, OP is welcome to try those changes and see if it helps their problem

leo60228 commented 1 month ago

For clarification: NixOS specifically sets -Werror=format-security, not -Werror. Fedora does the same thing when building packages, and nix-shell (the primary way to manage library dependencies for development on NixOS) uses the same compilation flags as "real" packages by design.