Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/47908 )
Change subject: Makefile: Explicitly set '-std=c99 -D_GNU_SOURCE' ......................................................................
Makefile: Explicitly set '-std=c99 -D_GNU_SOURCE'
Fix dmi.c while we are here to avoid a re-define of _GNU_SOURCE.
BUG=none TEST=`make` with both gcc and clang.
Change-Id: I4f973927fc018510a3beaa6c4fa2f356c77c7a6e Signed-off-by: Edward O'Callaghan quasisec@google.com --- M Makefile M dmi.c 2 files changed, 3 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/08/47908/1
diff --git a/Makefile b/Makefile index 0498624..b9e3244 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ DIFF = diff PREFIX ?= /usr/local MANDIR ?= $(PREFIX)/share/man -CFLAGS ?= -Os -Wall -Wextra -Wno-unused-parameter -Wshadow -Wmissing-prototypes -Wwrite-strings +CFLAGS ?= -std=c99 -D_GNU_SOURCE -Os -Wall -Wextra -Wno-unused-parameter -Wshadow -Wmissing-prototypes -Wwrite-strings EXPORTDIR ?= . RANLIB ?= ranlib PKG_CONFIG ?= pkg-config diff --git a/dmi.c b/dmi.c index c44221c..3b717cd 100644 --- a/dmi.c +++ b/dmi.c @@ -19,7 +19,9 @@
/* strnlen is in POSIX but was a GNU extension up to glibc 2.10 */ #if (__GLIBC__ == 2 && __GLIBC_MINOR__ < 10) || __GLIBC__ < 2 +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif /* !GNU_SOURCE */ #else #define _POSIX_C_SOURCE 200809L #endif
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/47908 )
Change subject: Makefile: Explicitly set '-std=c99 -D_GNU_SOURCE' ......................................................................
Patch Set 1:
Please always test such heavy changes on many host systems, (e.g. with manibuilder) to make sure there's not more GNUism than non-gnu systems can take.
Hello Sam McNally, build bot (Jenkins), Nico Huber, Angel Pons,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/47908
to look at the new patch set (#2).
Change subject: Makefile: Explicitly set '-std=c99 -D_GNU_SOURCE' ......................................................................
Makefile: Explicitly set '-std=c99 -D_GNU_SOURCE'
This matches the build flags that are correctly explicitly defined in meson.build where-as the Makefile is randomly picking up whatever the system toolchain happens to default to.
Fix dmi.c while we are here to avoid a re-define of _GNU_SOURCE.
BUG=none TEST=`make` with both gcc and clang.
Change-Id: I4f973927fc018510a3beaa6c4fa2f356c77c7a6e Signed-off-by: Edward O'Callaghan quasisec@google.com --- M Makefile M dmi.c 2 files changed, 3 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/08/47908/2
Hello Sam McNally, build bot (Jenkins), Nico Huber, Angel Pons,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/47908
to look at the new patch set (#3).
Change subject: Makefile: Explicitly set '-std=c99' ......................................................................
Makefile: Explicitly set '-std=c99'
This matches the build flags that are correctly explicitly defined in meson.build where-as the Makefile is randomly picking up whatever the system toolchain happens to default to.
Fix dmi.c while we are here to avoid a re-define of _GNU_SOURCE.
BUG=none TEST=`make` with both gcc and clang.
Change-Id: I4f973927fc018510a3beaa6c4fa2f356c77c7a6e Signed-off-by: Edward O'Callaghan quasisec@google.com --- M Makefile M dmi.c 2 files changed, 3 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/08/47908/3
Attention is currently required from: Edward O'Callaghan. Stefan Reinauer has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/47908 )
Change subject: Makefile: Explicitly set '-std=c99' ......................................................................
Patch Set 3: Code-Review+2
Attention is currently required from: Edward O'Callaghan. Stefan Reinauer has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/47908 )
Change subject: Makefile: Explicitly set '-std=c99' ......................................................................
Patch Set 3:
(2 comments)
File dmi.c:
https://review.coreboot.org/c/flashrom/+/47908/comment/3d245bf8_af41d1a8 PS3, Line 23: #define _GNU_SOURCE is there a downside to setting this explicitly in the build system?
https://review.coreboot.org/c/flashrom/+/47908/comment/27b96681_cc3d1a08 PS3, Line 26: #define _POSIX_C_SOURCE 200809L isn't this set explicitly now?
Attention is currently required from: Edward O'Callaghan. Sam McNally has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/47908 )
Change subject: Makefile: Explicitly set '-std=c99' ......................................................................
Patch Set 3: Code-Review+2
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/47908 )
Change subject: Makefile: Explicitly set '-std=c99' ......................................................................
Patch Set 3:
(2 comments)
File dmi.c:
https://review.coreboot.org/c/flashrom/+/47908/comment/5c4de87f_057d8947 PS3, Line 23: #define _GNU_SOURCE
is there a downside to setting this explicitly in the build system?
I originally did however it is a little too big of a net to say everything is GNU C which it isn't.
https://review.coreboot.org/c/flashrom/+/47908/comment/29705e5e_ca9ed680 PS3, Line 26: #define _POSIX_C_SOURCE 200809L
isn't this set explicitly now?
Yes it is, although I left dmi.c to be self-contained as it looks like it could be used in other places.
Edward O'Callaghan has submitted this change. ( https://review.coreboot.org/c/flashrom/+/47908 )
Change subject: Makefile: Explicitly set '-std=c99' ......................................................................
Makefile: Explicitly set '-std=c99'
This matches the build flags that are correctly explicitly defined in meson.build where-as the Makefile is randomly picking up whatever the system toolchain happens to default to.
Fix dmi.c while we are here to avoid a re-define of _GNU_SOURCE.
BUG=none TEST=`make` with both gcc and clang.
Change-Id: I4f973927fc018510a3beaa6c4fa2f356c77c7a6e Signed-off-by: Edward O'Callaghan quasisec@google.com Reviewed-on: https://review.coreboot.org/c/flashrom/+/47908 Reviewed-by: Stefan Reinauer stefan.reinauer@coreboot.org Reviewed-by: Sam McNally sammc@google.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M Makefile M dmi.c 2 files changed, 3 insertions(+), 1 deletion(-)
Approvals: build bot (Jenkins): Verified Stefan Reinauer: Looks good to me, approved Sam McNally: Looks good to me, approved
diff --git a/Makefile b/Makefile index 09b2154..6d37d55 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ DIFF = diff PREFIX ?= /usr/local MANDIR ?= $(PREFIX)/share/man -CFLAGS ?= -Os -Wall -Wextra -Wno-unused-parameter -Wshadow -Wmissing-prototypes -Wwrite-strings +CFLAGS ?= -std=c99 -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L -D_BSD_SOURCE -Os -Wall -Wextra -Wno-unused-parameter -Wshadow -Wmissing-prototypes -Wwrite-strings EXPORTDIR ?= . RANLIB ?= ranlib PKG_CONFIG ?= pkg-config diff --git a/dmi.c b/dmi.c index c44221c..3b717cd 100644 --- a/dmi.c +++ b/dmi.c @@ -19,7 +19,9 @@
/* strnlen is in POSIX but was a GNU extension up to glibc 2.10 */ #if (__GLIBC__ == 2 && __GLIBC_MINOR__ < 10) || __GLIBC__ < 2 +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif /* !GNU_SOURCE */ #else #define _POSIX_C_SOURCE 200809L #endif
Idwer Vollering has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/47908 )
Change subject: Makefile: Explicitly set '-std=c99' ......................................................................
Patch Set 5:
(1 comment)
Patchset:
PS5: GNU extensions break compilation (on at least one OS) outside linux. What's the rationale behind adding -D_POSIX_C_SOURCE=200809L?
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/47908 )
Change subject: Makefile: Explicitly set '-std=c99' ......................................................................
Patch Set 5:
(1 comment)
Patchset:
PS5:
GNU extensions break compilation (on at least one OS) outside linux. […]
Hi Idwer, POSIX_C_SOURCE=200809L is required for fileno, nanosleep, and strndup. This isn't the same thing as -D_GNU_SOURCE. We just make the assumptions from the toolchain explicit with flags in this commit, this should be a nop across any and all OS's we build on. If you know of a specific case where something is actually broken can you point that out so we can investigate?
Idwer Vollering has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/47908 )
Change subject: Makefile: Explicitly set '-std=c99' ......................................................................
Patch Set 5:
(1 comment)
Patchset:
PS5:
Hi Idwer, POSIX_C_SOURCE=200809L is required for fileno, nanosleep, and strndup. […]
Hi Edward,
'gmake' on BSD is broken, and hacks (see git diff) yet have to act as intended: https://paste.flashrom.org/view.php?id=3438
There was an issue with cbfstool earlier, having had a look at OS code I conclused that it should be solvable. https://github.com/freebsd/freebsd-src/blob/main/sys/sys/types.h#L55 https://review.coreboot.org/c/coreboot/+/49314
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/47908 )
Change subject: Makefile: Explicitly set '-std=c99' ......................................................................
Patch Set 5:
(1 comment)
Patchset:
PS5:
Hi Edward, […]
I see, what if we use -D_DEFAULT_SOURCE instead of -D_POSIX_C_SOURCE=200809L? The combinatorics of XOPEN/POSIX and so on are pretty hairy to figure out precisely what is best here however we just need to make explicit what we actually require.
Attention is currently required from: Edward O'Callaghan. Idwer Vollering has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/47908 )
Change subject: Makefile: Explicitly set '-std=c99' ......................................................................
Patch Set 5:
(1 comment)
Patchset:
PS5:
I see, what if we use -D_DEFAULT_SOURCE instead of -D_POSIX_C_SOURCE=200809L? The combinatorics of […]
I can live with that. The macro/extension definition is already used, though.
Attention is currently required from: Edward O'Callaghan. Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/47908 )
Change subject: Makefile: Explicitly set '-std=c99' ......................................................................
Patch Set 5:
(1 comment)
File Makefile:
https://review.coreboot.org/c/flashrom/+/47908/comment/e1930e74_8001a8a0 PS5, Line 33: CFLAGS ?= -std=c99 -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L -D_BSD_SOURCE -Os -Wall -Wextra -Wno-unused-parameter -Wshadow -Wmissing-prototypes -Wwrite-strings This breaks DJGPP
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/47908 )
Change subject: Makefile: Explicitly set '-std=c99' ......................................................................
Patch Set 5:
(1 comment)
Patchset:
PS5: Anastasia or Nikolai, can you possibly look into this while I am OOO please?
Angel Pons has created a revert of this change. ( https://review.coreboot.org/c/flashrom/+/47908 )
Change subject: Makefile: Explicitly set '-std=c99' ......................................................................
Anastasia Klimchuk has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/47908 )
Change subject: Makefile: Explicitly set '-std=c99' ......................................................................
Patch Set 5:
(1 comment)
Patchset:
PS5:
Anastasia or Nikolai, can you possibly look into this while I am OOO please?
Yes I will try to do what I can.