Commit Graph

142 Commits

Author SHA1 Message Date
Mike Frysinger 416792d59a newlib: libc: delete crt0.o duplication
The crt0.o was handled in a subdir-by-subdir basis: it would be compiled
in one (e.g. libc/sys/$arch/), then copied up one level (libc/sys/), then
copied up another (libc/) before finally being copied & installed in the
top newlib dir.  The libc/sys/ copy was cleaned up, and then the top dir
was changed to copy it directly out of the libc/sys/$arch/ dir.  But the
libc/sys/ copy to libc/ was left behind.  Clean that up now too.
2022-02-18 21:25:32 -05:00
Mike Frysinger 56c65fb8d9 newlib: posix: use local includes for local headers
These headers aren't installed, so use "" includes instead of <> so
we don't search system header paths.  This matches the style used
elsewhere in the tree for these local headers, and makes it work
w/out explicit -I flags (as needed with non-recursive make).
2022-02-18 18:40:57 -05:00
Mike Frysinger 907764ebec newlib/libgloss: drop unused $(CROSS_CFLAGS)
This is used in a bunch of places, but nowhere is it ever set, and
nowhere can I find any documentation, nor can I find any other project
using it.  So delete the flags to simplify.
2022-02-15 20:02:51 -05:00
Mike Frysinger ac90a6590b newlib: phoenix: merge configure up to top-level
Merge sys/phoenix/ configure logic into libc/ itself.  This kills
off the last lingering script in this tree (other than libc itself).
2022-02-15 19:59:08 -05:00
Mike Frysinger 5b9c4cf23e newlib: drop support for $oext
This was needed only to support libtool in case objects ended in .lo
instead of .o, but we dropped libtool, so drop this too.
2022-02-09 23:35:23 -05:00
Mike Frysinger f034d8ad19 newlib: drop support for $aext
This was needed only to support libtool in case the library ended in
.la instead of .a, but we dropped libtool, so drop this too.
2022-02-09 23:34:17 -05:00
Mike Frysinger 006da84337 newlib: drop libtool support
This was only ever used for i?86-pc-linux-gnu targets, but that's been
broken for years, and has since been dropped.  So clean this up too.

This also deletes the funky objectlist logic since it only existed for
the libtool libraries.  Since it was the only thing left in the small
Makefile.shared file, we can punt that too.
2022-02-09 20:27:37 -05:00
Mike Frysinger e7ad3f5aa8 newlib: switch to AM_PROG_AR
Now that we require automake-1.15, we can use this macro rather than
do the tool search ourselves.
2022-02-08 21:24:59 -05:00
Mike Frysinger b9346cee1a newlib: switch to standard AC_PROG_CC
Now that we use AC_NO_EXECUTABLES, and we require a recent version of
autoconf, we don't need to define our own copies of these macros.  So
switch to the standard AC_PROG_CC.
2022-02-08 19:09:26 -05:00
Mike Frysinger 24b1e4b942 newlib: drop shared documentation rules
Now that the top-level makefile handles these, don't need to copy
these into every single subdir.
2022-02-05 00:18:01 -05:00
Mike Frysinger 6026ef29d8 newlib: move man page generation into top-level build
This allows building the libc & libm pages in parallel, and drops
the duplication in the subdirs with the chew/chapter settings.

The unused rules in Makefile.shared are left in place to minimize
noise in the change.
2022-02-05 00:17:54 -05:00
Mike Frysinger fc2b4ffee0 newlib: libc: move manual into top-level build
This doesn't migrate all the docs, just the libc's manual (pdf/info).
This is to show the basic form of migrating the chew files.

For subdirs that didn't have any docs, I've stripped their settings
for clarity.  If someone wanted to suddenly add docs, they can add
the corresponding Makefile.inc files easily.
2022-02-04 23:57:12 -05:00
Mike Frysinger 44f6310bf9 newlib: libc: include all chapters all the time in the manual
THe stdio subdir is actually required by the documentation.  The
stdio/def is handled dynamically, but libc.texi always expects it
to be included, and fails if it isn't.  So making it required when
building docs is safe.

The xdr subdir is handled dynamically, but it doesn't include any
docs, so the dynamic logic isn't (currently) adding any value.  So
making it required when building docs is safe.

That leaves: iconv, stdio64, posix, and signal subdirs.  The chapters
have a little disclaimer saying they are system-dependent, but even
then, imo having stable manuals regardless of the target is preferable,
and we can add more disclaimer language to these chapters if we want.

This doesn't touch the man page codepaths, just the info/pdf.
2022-02-04 19:39:09 -05:00
Mike Frysinger 6444f108d9 newlib: export abs_newlib_basedir for all subdirs
When using the top-level configure script but subdir Makefiles, the
newlib_basedir value gets a bit out of sync: it's relative to where
configure lives, not where the Makefile lives.  Move the abs setting
from the top-level configure script into acinclude.m4 so we can rely
on it being available everywhere.  Although this commit doesn't use
it anywhere, just lays the groundwork.
2022-01-29 01:35:30 -05:00
Mike Frysinger 08a55a233d newlib: libc: merge machine/ configure scripts up a level
The machine configure scripts are all effectively stub scripts that
pass the higher level options to its own makefile.  There were only
three doing custom tests.  The rest were all effectively the same as
the libc/ configure script.

So instead of recursively running configure in all of these subdirs,
generate their makefiles from the top-level configure.  For the few
unique ones, deploy a pattern of including subdir logic via m4:
	m4_include([machine/nds32/acinclude.m4])

Some of the generated machine makefiles have a bunch of extra stuff
added to them, but that's because they were inconsistent in their
configure libtool calls.  The top-level has it, so it exports some
new vars to the ones that weren't already.
2022-01-26 03:11:21 -05:00
Mike Frysinger fbfeebc221 newlib: libc: merge sys/ trampoline up a level
The sys/{configure,Makefile} files exist to fan out to the specific
sys/$arch/ subdir, and to possibly generate a crt0.  We already have
all that same info in the libc/ dir itself, so by moving the recursive
configure and make calls into it, we can cut off some of this logic
entirely and save the overhead.

For arches that don't have a sys subdir, it means they can skip the
logic entirely.

The sys subdir itself is kept for the crt0 logic, for now.  We'll try
and clean that up next.
2022-01-26 03:11:20 -05:00
Mike Frysinger db2ef77287 newlib: libc: merge machine/ trampoline up a level
The machine/{configure,Makefile} files exist only to fan out to the
specific machine/$arch/ subdir.  We already have all that same info
in the libc/ dir itself, so by moving the recursive configure and
make calls into it, we can cut off this logic entirely and save the
overhead.

For arches that don't have a machine subdir, it means they can skip
the logic entirely.  Although there's prob not too many of those.
2022-01-26 03:11:20 -05:00
Mike Frysinger dcb25665be newlib: punt unused LIBC_EXTRA_LIB settings
This was added decades ago, but the commit message lacks any
explanation, and it was unused when it was merged.  It's still
unused today.  So punt it all.
2022-01-21 17:29:46 -05:00
Mike Frysinger 20e3103471 newlib: update to automake-1.15
This matches what the other GNU toolchain projects have done already.
The generated diff in practice isn't terribly large.  This will allow
more use of subdir local.mk includes due to fixes & improvements that
came after the 1.11 release series.
2022-01-14 19:10:38 -05:00
Mike Frysinger a100e80fc9 require autoconf-2.69 exactly
The newlib & libgloss dirs are already generated using autoconf-2.69.
To avoid merging new code and/or accidental regeneration using diff
versions, leverage config/override.m4 to pin to 2.69 exactly.  This
matches what gcc/binutils/gdb are already doing.

The README file already says to use autoconf-2.69.

To accomplish this, it's just as simple as adding -I flags to the
top-level config/ dir when running aclocal.  This is because the
override.m4 file overrides AC_INIT to first require the specific
autoconf version before calling the real AC_INIT.
2022-01-14 15:24:33 -05:00
Corinna Vinschen 935c33877d posix_spawn: fix get/set uid/gid calls for 32 bit Cygwin
32 bit Cygwin still exports function calls to support old applications.
E. g., when switching from 16 to 32 bit uid/gid values, new function
like getuid32 have been added and the old getuid function still only
provides 16 bit values.  Newly built applications using getuid are
actually calling getuid32.

However, this link magic isn't performed inside Cygwin itself, so if
newlib functions call getuid, they actually call the old getuid, not
the new getuid32.  This leads to truncated uid/gid values.

https://cygwin.com/pipermail/cygwin/2022-January/250453.html reports
how this leads to problems in posix_spawn.

Fix this temporarily. i686 support will go away soon in Cygwin and the
fix can be dropped.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-01-12 11:57:35 +01:00
Keith Thompson d4e61b73a9 Fix documented argv and envp params for posix_spawn 2022-01-10 09:57:05 +01:00
Mike Frysinger ed20821a40 newlib: migrate from INCLUDES to AM_CPPFLAGS
Since automake deprecated the INCLUDES name in favor of AM_CPPFLAGS,
change all existing users over.  The generated code is the same since
the two variables have been used in the same exact places by design.

There are other cleanups to be done, but lets focus on just renaming
here so we can upgrade to a newer automake version w/out triggering
new warnings.
2022-01-05 20:29:53 -05:00
Jon Turney bfcabeb876
newlib: Regenerate autotools files 2021-12-29 22:45:06 +00:00
Jon Turney a4e734fcdb
newlib: Remove automake option 'cygnus'
The 'cygnus' option was removed from automake 1.13 in 2012, so the
presence of this option prevents that or a later version of automake
being used.

A check-list of the effects of '--cygnus' from the automake 1.12
documentation, and steps taken (where possible) to preserve those
effects (See also this thread [1] for discussion on that):

[1] https://lists.gnu.org/archive/html/bug-automake/2012-03/msg00048.html

1. The foreign strictness is implied.

Already present in AM_INIT_AUTOMAKE in newlib/acinclude.m4

2. The options no-installinfo, no-dependencies and no-dist are implied.

Already present in AM_INIT_AUTOMAKE in newlib/acinclude.m4

Future work: Remove no-dependencies and any explicit header dependencies,
and use automatic dependency tracking instead.  Are there explicit rules
which are now redundant to removing no-installinfo and no-dist?

3. The macro AM_MAINTAINER_MODE is required.

Already present in newlib/acinclude.m4

Note that maintainer-mode is still disabled by default.

4. Info files are always created in the build directory, and not in the
source directory.

This appears to be an error in the automake documentation describing
'--cygnus' [2]. newlib's info files are generated in the source
directory, and no special steps are needed to keep doing that.

[2] https://lists.gnu.org/archive/html/bug-automake/2012-04/msg00028.html

5. texinfo.tex is not required if a Texinfo source file is specified.
(The assumption is that the file will be supplied, but in a place that
automake cannot find.)

This effect is overriden by an explicit setting of the TEXINFO_TEX
variable (the directory part of which is fed into texi2X via the
TEXINPUTS environment variable).

6. Certain tools will be searched for in the build tree as well as in the
user's PATH. These tools are runtest, expect, makeinfo and texi2dvi.

For obscure automake reasons, this effect of '--cygnus' is not active
for makeinfo in newlib's configury.

However, there appears to be top-level configury which selects in-tree
runtest, expect and makeinfo, if present. So, if that works as it
appears, this effect is preserved. If not, this may cause problem if
anyone is building those tools in-tree.

This effect is not preserved for texi2dvi. This may cause problems if
anyone is building texinfo in-tree.

If needed, explicit checks for those tools looking in places relative to
$(top_srcdir)/../ as well as in PATH could be added.

7. The check target doesn't depend on all.

This effect is not preseved. The check target now depends on the all
target.

This concern seems somewhat academic given the current state of the
testsuite.

Also note that this doesn't touch libgloss.
2021-12-29 22:45:04 +00:00
Jon Turney 8e166351b3
newlib: Regenerate autotools files 2021-12-29 22:45:03 +00:00
Jon Turney 639cb7ec1a
newlib: Regenerate all autotools files
Regenerate all aclocal.m4, configure and Makefile.in files.
2021-12-09 21:41:35 +00:00
Mike Frysinger 59e83de0b1 libgloss/newlib: update configure.ac in Makefile.in files
The maintainer rules refer to configure.in directly, so update that
after renaming all the configure.ac files.
2021-11-06 14:14:49 -04:00
Corinna Vinschen 6a35ae33f5 nftw: fix thread cancellation support
_STDIO_WITH_THREAD_CANCELLATION_SUPPORT was never defined.
Include ../stdio/local.h to get the right definition per target.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-09-03 12:26:17 +02:00
Corinna Vinschen 80bd01ef83 Add build mechanism to share common header files between machines
So far the build mechanism in newlib only allowed to either define
machine-specific headers, or headers shared between all machines.
In some cases, architectures are sufficiently alike to share header
files between them, but not with other architectures.  A good example
is ix86 vs. x86_64, which share certain traits with each other, but
not with other architectures.

Introduce a new configure variable called "shared_machine_dir".  This
dir can then be used for headers shared between architectures.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-13 12:55:33 +02:00
Jeff Johnston 1debd4d635 Regenerate lib/posix/Makefile.in 2021-03-05 15:23:24 -05:00
Eshan dhawan d8ee634506 FTW Port for Newlib
Signed-off-by: Eshan Dhawan <eshandhawan51@gmail.com>
2021-02-09 11:07:59 +01:00
Corinna Vinschen 3fbfcd11fb Cygwin: posix_spawn: add Cygwin-specific code fixing process synchronisation
Newlib's posix_spawn has been taken from FreeBSD.  The code relies on
BSD-specific behaviour of vfork, namely the fact that vfork blocks
the parent until the child exits or calls execve as well as the fact
that the child shares parent memory in non-COW mode.

This behaviour can't be emulated by Cygwin.  Cygwin's vfork is
equivalent to fork.  This is POSIX-compliant, but it's lacking BSD's
vfork ingrained synchronization of the parent to wait for the child
calling execve, or the chance to just write a variable and the parent
will see the result.

So this requires a Cygwin-specific solution.  The core function of
posix_spawn, called do_posix_spawn is now implemented twice, once using
the BSD method, and once for Cygwin using Windows synchronization under
the hood waiting for the child to call execve and signalling errors
upstream.  The Windows specifics are hidden inside Cygwin, so newlib
only calls internal Cygwin functions.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-08-03 12:41:44 +02:00
Keith Packard 9042d0ce65 Use remove-advertising-clause script to edit BSD licenses
This edits licenses held by Berkeley and NetBSD, both of which
have removed the advertising requirement from their licenses.

Signed-off-by: Keith Packard <keithp@keithp.com>
2020-01-29 19:03:31 +01:00
Sebastian Huber 3e24fbf6f0 scandir: Add support for struct dirent::d_type
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2019-02-01 10:37:00 +01:00
ache 67613cbbd8 a) Use strcoll() in opendir() and alphasort()
as POSIX 2008 requires. It also matches now how our 'ls' works for years.

b) Remove comment expressed 2 fears:
 1) One just simple describe how strcoll() works in _any_ context,
 not for directories only. Are we plan to remove strcoll() from everything
 just because it is little more complex than strcmp()? I doubt, and
 directories give nothing different here. Moreover, strcoll() used
 in 'ls' for years and nobody complaints yet.

 2) Plain wrong statement about undefined strcoll() behaviour. strcoll()
 always gives predictable results, falling back to strcmp() on any
 trouble, see strcoll(3).

No objections from -current list discussion.
2019-02-01 10:37:00 +01:00
das 2d3c2f4697 scandir(3) previously used st_size
to obtain an initial estimate of the array length needed to store all
the directory entries. Although BSD has historically guaranteed that
st_size is the size of the directory file, POSIX does not, and more to
the point, some recent filesystems such as ZFS use st_size to mean
something else.

The fix is to not stat the directory at all, set the initial
array size to 32 entries, and realloc it in powers of 2 if that
proves insufficient.

PR:	113668
2019-02-01 10:36:40 +01:00
obrien d785551a46 Remove __P and convert to ANSI prototypes.
* Fix SCM ID's.
2019-02-01 10:33:14 +01:00
jhb 0e7db0c356 Clean up the vcs ID strings
in libc's gen/ directory.

- Move CSRG IDs into __SCCSID().
- When a file has been copied, consistently use 'From: <tag>' for strings
  referencing the version of the source file copied from in the license
  block comment.
- Some of the 'From:' tags were using $FreeBSD$ that was being expanded on
  each checkout.  Fix those to hardcode the FreeBSD tag from the file that
  was copied at the time of the copy.
- When multiple strings are present list them in "chronological" order,
  so CSRG (__SCCSID) before FreeBSD (__FBSDID).  If a file came from
  OtherBSD and contains a CSRG ID from the OtherBSD file, use the order
  CSRG -> OtherBSD -> FreeBSD.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D15831
2019-02-01 10:32:24 +01:00
imp b46ef7699f Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2019-02-01 10:32:24 +01:00
Sebastian Huber 62fb0614c6 scandir: Update copyright notice from FreeBSD
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2019-02-01 10:32:24 +01:00
pfg 24629e9701 General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2019-02-01 10:32:24 +01:00
Sebastian Huber 103b055035 Add generic implementation of fdopendir()
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-11 08:29:17 +02:00
Sebastian Huber ab4fdab5d5 Add generic implementation of dirfd()
Use existing HAVE_OPENDIR define to determine if a generic
implementation should be provided.  Cygwin for example has its own
implementation of opendir() and dirfd().

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-11 08:29:16 +02:00
Sebastian Huber 61fc64ed97 Open a directory with the usual flags
Use O_RDONLY since you are not supposed to write to a directory.

Use O_DIRECTORY as mandated by POSIX (The Open Group Base Specifications
Issue 7, 2018 edition IEEE Std 1003.1-2017):

"If the type DIR is implemented using a file descriptor, the descriptor
shall be obtained as if the O_DIRECTORY flag was passed to open()."

Use O_CLOEXEC as mandated by POSIX:

"When a file descriptor is used to implement the directory stream, it
behaves as if the FD_CLOEXEC had been set for the file descriptor."

Drop the fcntl() call in favour of O_CLOEXEC.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-11 08:29:16 +02:00
Corinna Vinschen 5ace9004d9 newlib: wordexp: drop dangerous fprintf
wordexp uses fprintf in a dangerous way.  It uses an unchecked
input string as format string, rather than as parameter to a %s.
Replace fprintf with fputs.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-08-08 10:50:19 +02:00
Yaakov Selkowitz 7192f84096 ansification: remove _HAVE_STDC
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:30 -06:00
Yaakov Selkowitz 9087163804 ansification: remove _DEFUN
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:26 -06:00
Yaakov Selkowitz 2310096fbc ansification: remove _DOTS
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:10 -06:00
Yaakov Selkowitz 0bda30e1ff ansification: remove _CONST
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:08 -06:00