Commit Graph

3455 Commits

Author SHA1 Message Date
Jeff Johnston 0239bc706a Commit patch from Tobias Burnus <tobias@codesourcery.com>
[PATCH] newlib: Only call _fputwc_r if ELIX_LEVEL >= 4

(nano-)vfprintf.c is enabled for ELIX_LEVEL >= 1. When _WIDE_ORIENT
is set, its __sprint_r / __sfputs_r functions unconditionally called
_fputwc_r which is only in ELEX_LEVEL >= 4. With this commit,
the _WIDE support in (nano-)vfprintf.c is disabled for ELEX_LEVEL < 4.
2022-03-30 15:58:06 -04:00
Mike Frysinger be9c0561e7 newlib: drop phoenix support
This code has not been updated since 2016, and it looks like it has
rotted quite a bit since.  It does not build against the current set
of phoenix sources -- I had to hack both the kernel headers and the
newlib headers up to get it to build, and I still have no idea if it
actually links or runs.  It seems like the project itself has moved
away from newlib and to its own C library:
https://phoenix-rtos.com/documentation/libc/README.md

So since there's no interest from the phoenix folks to maintain this,
and it has a significant amount of non-standard code that we try to
keep up-to-date (without actually testing it), just punt it all.
2022-03-28 23:17:06 -04:00
Andrew Stubbs 761ef3b434 amdgcn: Fix build failure
The recent makefile reorganization broke the amdgcn port by creating
duplicate __malloc_lock symbols.  This patch fixes the problem by renaming
the malloc_support.c file to mlock.c, thus overriding the default symbol
properly.  Actually, I'm not sure how this ever worked?
2022-03-22 21:45:16 -04:00
Sebastian Huber 64b208103d iconv: Fix EL/IX level 2 handling
Consistently use

	if !ELIX_LEVEL_1

to enable EL/IX level 2 interfaces.
2022-03-21 11:32:59 +01:00
Jeff Law 0c8679e080 Avoid using common symbols in v850 libgloss
I've had this lying around for probably a year or two at this point.
It just changes all the instance of "errno" from a common symbol to an
extern.  I can't offhand recall where the actual definition is, but it
certainly exists in the generic code.
2022-03-19 20:01:33 -04:00
Mike Frysinger d88cbd0e7c newlib: enable automatic dependency generation
This was disabled as part of the migration away from the cygnus option
as that implied no-dependencies.

We currently have 1-to-1 updates enabled -- if you touch a .c file,
the corresponding .o file will be rebuilt.  But if you touch a header
file, none of the files using that get rebuilt.
2022-03-17 20:38:17 -04:00
Mike Frysinger fb42151a18 newlib: libm: integrate tests subdir
Integrate the old libm/test/ subdir into the main build.  It hasn't
been used in a long time causing the code to rot a bit.  I've fixed
some of those, but it still fails for many ports, so it's disabled
by default.  People who want to take a closer look can run:
$ make libm/test/test
2022-03-16 22:01:19 -04:00
Mike Frysinger 958833a0d3 newlib: integrate iconv update to maintainer build
To help prevent people from missing running this script, integrate it
into the build via maintainer mode.

Also fix the inverted exit status to make this work correctly -- for
some reason, it exited 1 when it worked, and 0 when it failed.
2022-03-16 21:59:57 -04:00
Mike Frysinger f2471da7db newlib: update build system generation documentation
Replace all of the individual autotool steps with a single autoreconf.
This simplifies the documentation greatly, and in the current system,
only takes ~10 seconds to regenerate everything.

Update the developer documentation to cover all the major components
of the current build system.  Hopefully this is a fairly complete road
map to everything.  I tried to include everything that I wish I knew
when I started hacking on this :P.
2022-03-16 21:59:09 -04:00
Mike Frysinger 96bc16f6b2 newlib: libc: merge build up a directory
Convert all the libc/ subdir makes into the top-level Makefile.  This
allows us to build all of libc from the top Makefile without using any
recursive make calls.  This is faster and avoids the funky lib.a logic
where we unpack subdir archives to repack into a single libc.a.  The
machine override logic is maintained though by way of Makefile include
ordering, and source file accumulation in libc_a_SOURCES.

There's a few dummy.c files that are no longer necessary since we aren't
doing the lib.a accumulating, so punt them.

The winsup code has been pulling the internal newlib ssp library out,
but that doesn't exist anymore, so change that to pull the objects.
2022-03-16 21:18:25 -04:00
Mike Frysinger b2d4dc167c newlib: xstormy16: move malloc multiplex logic from build to source files
Rather than define per-object rules in the Makefile, have small files
that define & include the right content.  This simplifies the build
rules, and makes understanding the source a little easier (imo) as it
makes all the subdirs behave the same: you have 1 source file and it
produces 1 object.  It's also about the same amount of boiler plate,
without having to define custom build rules that can fall out of sync.

We also realign the free & pvalloc definitions: common code puts these
in malloc.o & valloc.o respectively, not in free.o & pvalloc.o objects.

This will also be important as we merge the libc.a build into the top
dir since it relies on a single flat list of objects for overrides.
2022-03-13 17:12:03 -04:00
Mike Frysinger 8c383e9ae7 newlib: xstormy16: break up mallocr stubs
Move the multiplex logic out of the build and into source files to
make the build rules a lot simpler.
2022-03-13 17:12:03 -04:00
Mike Frysinger 5cd957ff66 newlib: xstormy16: fix mallopt definition & mstats handling
The mallopt symbol is defined in tiny-malloc.c, not mallocr.c, but
the Makefile in here tries to compile it out of the latter.  This
leads to mallopt never being defined.

The build also creates mallinfo.o & mallopt.o & mallstats.o objects
to override common ones, but the common dir doesn't use these names.
Instead, it places these all in mstats.o.

So move the build define logic to a dedicated file and compile it
directly to make things a bit simpler while fixing the missing func
and aligning objects with the cmomon code.
2022-03-13 17:12:03 -04:00
Mike Frysinger 4ad6b4d4df newlib: libc: move stdlib multiplex logic from build to source files
Rather than define per-object rules in the Makefile, have small files
that define & include the right content.  This simplifies the build
rules, and makes understanding the source a little easier (imo) as it
makes all the subdirs behave the same: you have 1 source file and it
produces 1 object.  It's also about the same amount of boiler plate,
without having to define custom build rules that can fall out of sync.

This will also be important as we merge the libc.a build into the top
dir since it relies on a single flat list of objects for overrides.

Also take the opportunity to clean up the unnecessary header deps in
here.  Automake provides dependency generation for free now.
2022-03-09 16:58:46 -05:00
Sebastian Huber 332df71d34 build: Avoid length() awk function
Some awk implementations such as old versions of mawk do not support the
length() function.  Use the return value of the POSIX split() function instead.
2022-03-09 12:04:11 +01:00
Mike Frysinger b1b44f777c newlib: rename mallocr.c to _mallocr.c
This file is a little confusing: it provides all of the mallocr logic,
but is compiled multiple times to produce a unique symbol each time.
For example, building mallocr.c with -DDEFINE_FREER produces freer.o
that only defines _free_r().  This is fine for most symbols, but it's
a little confusing when defining mallocr itself -- we produce a file
with the same symbol name, but we still need -DDEFINE_MALLOCR.  In
order to move the logic from the build rules to source files, using
mallocr.c both as a multiplexer and for defining a single symbol is a
bit tricky.  It's possible (if we add a lot of redundant preprocessor
checks to mallocr.c, or we add complicated build flags just for this
one files), but it's easier if we simply rename this to a dedicated
file.  So let's do that.

We do this as a dedicated commit because the next one will create a
new mallocr.c file and git's automatic diff algorithms can handle
trivial renames, but it can't handle renames+creates in the same
commit.
2022-03-09 04:12:46 -05:00
Mike Frysinger d7b16b0576 newlib: move nano-malloc logic from build to source files
Simplify the build system logic a bit by moving the mallocr.c ->
nano-mallocr.c redirection from the Makefile to the source files.
This allows for consistent object name usage regardless of the
configuration options used in case a machine dir wants to define
its own override.
2022-03-09 04:12:45 -05:00
Jeff Johnston 5fca4e0f18 Fix Bug libc/28945
- apply fix from Tom de Vries <vries@gcc.gnu.org>
  to have calloc zero out storage for nvptx calloc function
2022-03-07 15:35:02 -05:00
Mike Frysinger dea52d5c1e newlib: convert INTERNAL_NEWLIB to _LIBC
Since we already set up _LIBC to indicate source files are building
for newlib, we don't need this malloc-specific symbol.  Convert it
over to simplify the build a bit.
2022-03-01 20:30:32 -05:00
Mike Frysinger e15b2e8691 newlib: drop redundant AM_MAINTAINER_MODE call
This is already called earlier in this file, so no need to do it again.
2022-03-01 20:30:05 -05:00
Mike Frysinger 644e8bba07 newlib: xstormy16: add missing string.h include
Some of these functions are using memcpy & memset from string.h but
not including the header leading to implicit declaration warnings.
2022-03-01 01:14:33 -05:00
Mike Frysinger a531ad9726 newlib: speed up targ-include setup & add error checking
The current targ-include setup runs `cp` every header file it installs,
in serial.  This can be a little noticeable on systems, so cleanup the
logic to rely on cp's ability to copy multiple files to a directory in
a single call.

We still need a check for empty directories with no headers (i.e. the
glob doesn't match anything), so add a helper variable to contain that
logic to reduce the boiler plate a little.
2022-02-28 19:07:22 -05:00
Mike Frysinger 28724b2f62 newlib: libc: move stdio multiplex logic from build to source files
Rather than define per-object rules in the Makefile, have small files
that define & include the right content.  This simplifies the build
rules, and makes understanding the source a little easier (imo) as it
makes all the subdirs behave the same: you have 1 source file and it
produces 1 object.  It's also about the same amount of boiler plate,
without having to define custom build rules that can fall out of sync.
Some of these rules were already unnecessary as they were compiling a
single source file into the same named object w/out custom flags, and
Automake handles that for us completely.

This will also be important as we merge the libc.a build into the top
dir since it relies on a single flat list of objects for overrides.

Also take the opportunity to clean up the unnecessary header deps in
here.  Automake provides dependency generation for free now.
2022-02-28 19:04:11 -05:00
Mike Frysinger ec5ea6efae newlib: simplify header setup rules
Since POSIX cp requires copying a file to a directory without having
to specify the name explicitly, rely on that to avoid calling basename
on every source file.

We can also drop the stub `true` call if the -f test failed.  The use
of `if` already takes care of that in POSIX shell.
2022-02-28 19:03:57 -05:00
Mike Frysinger 8343db918f newlib: libc: move configure into top-level
This kills off the last configure script under libc/ and folds it
into the top newlib configure script.  The a lot of the logic was
already in the top configure script, so move what's left into a
libc/acinclude.m4 file.
2022-02-25 13:52:48 -05:00
Mike Frysinger 85f2dca52d newlib: add silent rules support to top-level rules 2022-02-24 19:14:12 -05:00
Mike Frysinger acf642177b newlib: fix multilib libg.a parallel builds
I split libg.a out into a sep target from libc.a for the main dir in
commit f2b053f49e ("newlib: separate out
libg from libc"), but missed the multilib dirs.  That leads to an
uncommon parallel build failure:
- libc.a rule runs & finishes
- $(BUILD_MULTISUBDIR)/libc.a rule runs
  -> failure due to libg.a not yet existing
- libg.a rule runs & finishes

Split the multilib libg rule out from libc too so it can depend on the
main libg directly and avoid this race.
2022-02-23 22:01:05 -05:00
Mike Frysinger 5ad394510b newlib: libm: workaround ar duplicate member behavior
GNU ar has undocumented behavior where it doesn't dedupe its inputs if
they're all on the same command line, so we have to dedupe ourselves.
2022-02-23 20:07:10 -05:00
Matt Joyce 44b60f0c4b Make __sdidinit unused
Remove dependency on __sdidinit member of struct _reent to check
object initialization. Like __sdidinit, the __cleanup member of
struct _reent is initialized in the __sinit() function. Checking
initialization against __cleanup serves the same purpose and will
reduce overhead in the __sfp() function in a follow up patch.
2022-02-22 12:38:46 +01:00
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 ac9f8c46b1 newlib: libm: merge build up a directory
Convert all the libm/ subdir makes into the top-level Makefile.  This
allows us to build all of libm from the top Makefile without using any
recursive make calls.  This is faster and avoids the funky lib.a logic
where we unpack subdir archives to repack into a single libm.a.  The
machine override logic is maintained though by way of Makefile include
ordering, and source file accumulation in libm_a_SOURCES.

One thing to note is that this will require GNU Make because of:
	libm_a_CFLAGS = ... $(libm_a_CFLAGS_$(subst /,_,$(@D)))
This was the only way I could find to supporting per-dir compiler
settings, and I couldn't find a POSIX compatible way of transforming
the variable content.  I don't think this is a big deal as other
Makefiles in the tree are using GNU Make-specific syntax, but I call
this out as it's the only one so far in the new automake code that
I've been writing.

Automake doesn't provide precise control over the output object names
(by design).  This is fine by default as we get consistent names in all
the subdirs: libm_a-<source>.o.  But this relies on using the same set
of compiler flags for all objects.  We currently compile libm/common/
with different optimizations than the rest.

If we want to compile objects differently, we can create an intermediate
archive with the subset of objects with unique flags, and then add those
objects to the main archive.  But Automake will use a different prefix
for the objects, and thus we can't rely on ordering to override.

But if we leverage $@, we can turn Automake's CFLAGS into a multiplex
on a per-dir (and even per-file if we wanted) basis.  Unfortunately,
since $@ contains /, Automake complains it's an invalid name.  While
GNU Make supports this, it's a POSIX extension, so Automake flags it.
Using $(subst) avoids the Automake warning to get a POSIX compliant
name, albeit with a GNU Make extension.
2022-02-17 20:56:32 -05:00
Mike Frysinger f2b053f49e newlib: separate out libg from libc
Make this a separate target from libc so that we can migrate libc over
to automake more easily.  Having it integrated into the libc target is
difficult to handle when using automake rules which expect a one-to-one
mapping between names & inputs.
2022-02-17 20:54:21 -05:00
Mike Frysinger c75bb30fc1 newlib: libc: reshuffle include order for the manual
When migrating the manual to the top-level, the include order was
sorted by name of the subdir.  But this changed the chapter order
of the manual in the process.  Change the sorting back to match
existing chapters and update the comments to explain.
2022-02-17 20:43:51 -05:00
Mike Frysinger 48942fe31a newlib: powerpc: switch to Automake conditionals
Using xxx_LIBADD, xxx_DEPENDENCIES, and EXTRA_xxx_SOURCES is one way of
conditionally including files into a target.  But it's meant more for the
cases where the variables added to LIBADD & DEPENDENCIES are constructed
via substitution (e.g. AC_SUBST) or other dynamic methods.  With Automake
conditionals, then the much simpler form is to conditionally append to
the xxx_SOURCES variable and let Automake sort everything out.
2022-02-17 20:43:51 -05:00
Mike Frysinger bf9f6a0984 newlib: use https:// URIs in more places 2022-02-17 00:48:58 -05:00
Mike Frysinger beadbdfc04 newlib: fix mips fenv.o handling
Commit 8fa73a9f84 changed how fenv.c is
compiled wrt mips16 targets used the wrong variable to add fenv.o to
libm.a.  Fix that thinko so it's included in the build again.
2022-02-16 20:40:53 -05:00
Mike Frysinger 2a83e65fc2 newlib: rtems: drop redundant header install
The top-level newlib dir already takes care of recursing into the
sys/xxx/include/ subdirs and installing any headers found, so the
rtems subdir doesn't need to do this itself.
2022-02-16 20:03:57 -05:00
Mike Frysinger 01ed65ed09 newlib: add missing mkdir to header install
Make sure these subdirs exist before trying to install headers into them.
2022-02-16 20:03:07 -05:00
Mike Frysinger 40748cd73a newlib: powerpc: simplify reallocr & callocr build logic
Replace the custom build rules (which require copying & pasting from the
current Makefile) with small stub files.  This allows us to drop the rules
entirely and let Automake provide everything.
2022-02-16 20:00:27 -05:00
Mike Frysinger d1591ed4a1 newlib: i386/xstormy16: drop unused -I libm/common flag
These subdirs don't actually use anything from libm.  The common dir
in particular only has 4 header files, and none are included here.

The xstormy16 code has a comment mentioning why this hack is here, but
it refers to code that was removed when its configure script was merged
up a level.
2022-02-16 19:58:13 -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 df5808b771 newlib: drop support for decstation & sunos systems
These targets don't actually cross-compile -- they try to pull some
objects out of the host's /lib/libc.a, /lib/libm.a, and /lib/crt0.o
directly and merge them into newlib's own libraries.  This is hard
to keep working and impossible to test.  Considering the vintage of
such targets, and gcc dropping them many many years ago, drop them
from newlib too.  This will make cleaning up the build a lot easier.
2022-02-15 20:00:58 -05:00
Mike Frysinger b7f2965dc3 newlib: rename doc/local.mk to Makefile.inc
For consistency across the whole tree.
2022-02-15 19:59:53 -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 86432e55b4 newlib: phoenix: 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.
2022-02-15 19:59:08 -05:00
Mike Frysinger d470ef6463 newlib: phoenix: 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 phoenix/ dir itself, so by moving the recursive configure and
make calls into it, we can cut off this logic entirely and save the
overhead.
2022-02-15 19:59:08 -05:00
Mike Frysinger 16c12761fd newlib: phoenix: drop missing machine subdirs
These were never added to the tree, and as we transition from autoconf
to automake, it really wants the latter subdirs to always exist.  These
don't, so delete the logic.
2022-02-15 19:59:08 -05:00
Mike Frysinger 5a6bf1749f newlib: phoenix: move some logic from configure to the Makefile
These configure scripts hardcode some settings, so move them to the
Makefile to simplify so we can drop the configure scripts entirely.
2022-02-15 19:59:08 -05:00
Andoni Arregi ec69debcb9 Improve lgammaf range for very small cases
The original cut for small arguments at |x|<2**-70 (copied from the
double version) produces that when computing nadj we get a subnormal
number for t*x and thus, the division of pi/subnormal will be INF and
the logarithm of it too, which is wrong as a result for lgammaf in this
range.
The proposed new limit seems to be safe and has been tested to
produce accurate results.
(Courtesy of Andreas Jung, ESA)
2022-02-14 14:44:11 +01:00