public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: newlib@sourceware.org
Subject: what's up with _COMPILING_NEWLIB
Date: Sat, 6 Nov 2021 20:21:03 -0400	[thread overview]
Message-ID: <YYcb752EA71AhfF3@vapier> (raw)

[-- Attachment #1: Type: text/plain, Size: 3830 bytes --]

i stumbled across _COMPILING_NEWLIB and it seems to be what i want: a symbol
that indicates the code currently being compiled is newlib itself so that the
header can change behavior for that environment specifically.  is that what
it's meant for ?

if so, why does it seem to be inconsistently defined ?  newlib/configure.host
will add it for a few random targets, as does the mips-specific
newlib/libc/machine/mips/Makefile.am, as do a few specific winsup/cygwin/
files.  it feels like the patch below is what we should have.

if that's not what this is for, is there a define that has this meaning ?
in the glibc & gnulib world, the plain _LIBC define indicates this.
-mike

--- a/newlib/configure.host
+++ b/newlib/configure.host
@@ -54,7 +54,7 @@
 #   have_init_fini	have init/fini ("yes" or "no", set to "yes" by default)
 #   noinclude		list of include files to not install
 
-newlib_cflags=
+newlib_cflags="-D_COMPILING_NEWLIB"
 libm_machine_dir=
 machine_dir=
 shared_machine_dir=
@@ -467,15 +467,11 @@ case "${host}" in
 	sys_dir=a29khif
 	signal_dir=
 	;;
-  aarch64*-*-*)
-	newlib_cflags="${newlib_cflags} -D_COMPILING_NEWLIB"
-	;;
   amdgcn*)
 	sys_dir=amdgcn
 	have_crt0="no"
 	;;
   arm*-*-*)
-	newlib_cflags="${newlib_cflags} -D_COMPILING_NEWLIB"
 	sys_dir=arm
 	if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
 	  have_crt0="no"
@@ -652,11 +648,11 @@ case "${host}" in
 	default_newlib_io_long_double="yes"
 	default_newlib_io_pos_args="yes"
 	CC="${CC} -I${cygwin_srcdir}/include"
-	newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DGETREENT_PROVIDED -DSIGNAL_PROVIDED -D_COMPILING_NEWLIB -DHAVE_BLKSIZE -DHAVE_FCNTL -DMALLOC_PROVIDED"
+	newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DGETREENT_PROVIDED -DSIGNAL_PROVIDED -DHAVE_BLKSIZE -DHAVE_FCNTL -DMALLOC_PROVIDED"
 	syscall_dir=syscalls
 	;;
   *-*-phoenix*)
-	newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -D_COMPILING_NEWLIB -DHAVE_BLKSIZE -DHAVE_NANOSLEEP"
+	newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DHAVE_BLKSIZE -DHAVE_NANOSLEEP"
 	default_newlib_io_long_long="yes"
 	syscall_dir=
 	;;
@@ -671,7 +667,6 @@ case "${host}" in
 	default_newlib_io_long_long="yes"
 	default_newlib_io_c99_formats="yes"
 	newlib_cflags="${newlib_cflags} -ffunction-sections -fdata-sections "
-	newlib_cflags="${newlib_cflags} -D_COMPILING_NEWLIB"
 newlib_cflags="${newlib_cflags} -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DEXIT_PROVIDED -DSIGNAL_PROVIDED -DGETREENT_PROVIDED -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_NANOSLEEP -DHAVE_BLKSIZE -DHAVE_FCNTL -DHAVE_ASSERT_FUNC"
         # turn off unsupported items in posix directory 
 	newlib_cflags="${newlib_cflags} -D_NO_GETLOGIN -D_NO_GETPWENT -D_NO_GETUT -D_NO_GETPASS -D_NO_SIGSET -D_NO_WORDEXP -D_NO_POPEN -D_NO_POSIX_SPAWN"
--- a/newlib/libc/machine/mips/Makefile.am
+++ b/newlib/libc/machine/mips/Makefile.am
@@ -9,8 +9,6 @@ AM_CCASFLAGS = $(INCLUDES)
 noinst_LIBRARIES = lib.a
 
 lib_a_SOURCES = setjmp.S strlen.c strcmp.S strncpy.c memset.S memcpy.S
-lib_a_CCASFLAGS=$(AM_CCASFLAGS) -D_COMPILING_NEWLIB
-lib_a_CFLAGS=$(AM_CFLAGS) -D_COMPILING_NEWLIB
 
 ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..
 CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
--- a/newlib/libc/machine/mips/Makefile.in
+++ b/newlib/libc/machine/mips/Makefile.in
@@ -198,8 +198,6 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
 AM_CCASFLAGS = $(INCLUDES)
 noinst_LIBRARIES = lib.a
 lib_a_SOURCES = setjmp.S strlen.c strcmp.S strncpy.c memset.S memcpy.S
-lib_a_CCASFLAGS = $(AM_CCASFLAGS) -D_COMPILING_NEWLIB
-lib_a_CFLAGS = $(AM_CFLAGS) -D_COMPILING_NEWLIB
 ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..
 CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
 all: all-am

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

             reply	other threads:[~2021-11-07  0:21 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-07  0:21 Mike Frysinger [this message]
2021-11-08 10:05 ` Corinna Vinschen
2021-11-08 11:46   ` Mike Frysinger
2021-11-08 15:05     ` Corinna Vinschen
2021-11-08 18:14       ` Mike Frysinger
2021-11-09  1:24 ` [PATCH 1/2] define _COMPILING_NEWLIB for all targets when compiling Mike Frysinger
2021-11-09  1:24   ` [PATCH 2/2] ctype: use less short names in public header Mike Frysinger
2021-11-09 11:38     ` Corinna Vinschen
2021-11-10  0:18       ` Mike Frysinger
2021-11-10 10:56         ` Corinna Vinschen
2021-11-30 12:18         ` Jonathan Wakely
2021-11-11  1:37     ` [PATCH v2] " Mike Frysinger
2021-11-11 10:35       ` Corinna Vinschen
2021-11-11 22:28         ` Mike Frysinger
2021-11-12 10:27           ` Corinna Vinschen
2021-11-20 20:08             ` Brian Inglis
2021-11-23 15:09     ` [PATCH 2/2] " Richard Earnshaw
2021-11-24  4:15       ` Mike Frysinger
2021-11-24 10:58         ` Richard Earnshaw
2021-11-24 11:01           ` Richard Earnshaw
2021-11-30 12:01         ` Jonathan Wakely
2021-11-30 15:14           ` Corinna Vinschen
2021-11-30 17:12             ` Jonathan Wakely
2021-11-30 17:15               ` Jonathan Wakely
2021-11-30 17:52                 ` Richard Earnshaw
2021-12-02 10:27                   ` Corinna Vinschen
2021-12-03  9:56                     ` Corinna Vinschen
2021-12-05  9:42                   ` Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YYcb752EA71AhfF3@vapier \
    --to=vapier@gentoo.org \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).