Mike Frysinger [Mon, 14 Feb 2022 02:43:37 +0000 (21:43 -0500)]
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.
Mike Frysinger [Sun, 13 Feb 2022 08:11:01 +0000 (03:11 -0500)]
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.
Takashi Yano [Fri, 11 Mar 2022 08:26:30 +0000 (17:26 +0900)]
Cygwin: path: Add fallback for DFS mounted drive.
- If UNC path for DFS is mounted to a drive with drive letter, the
error "Too many levels of symbolic links" occurs when accessing
to that drive. This is because GetDosDeviceW() returns unexpected
string such as "\Device\Mup\DfsClient\;Z:000000000003fb89\dfsserver
\dfs\linkname" for the mounted UNC path "\??\UNC\fileserver\share".
This patch adds a workaround for this issue.
Takashi Yano [Fri, 11 Mar 2022 21:19:53 +0000 (06:19 +0900)]
Cygwin: fsync: Return EINVAL for special files.
- Unlike linux, fsync() calls FlushFileBuffers() even for special
files. This causes the problem reported in:
https://cygwin.com/pipermail/cygwin/2022-March/251022.html
This patch fixes the issue.
Mike Frysinger [Tue, 1 Mar 2022 06:37:19 +0000 (01:37 -0500)]
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.
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.
Takashi Yano [Thu, 10 Mar 2022 11:20:00 +0000 (20:20 +0900)]
Cygwin: console, pty: Fix segfault in child_info_spawn::worker().
- After the commit "Cygwin: pty, console: Fix handle leak which
occurs on exec() error.", startxwin cannot start X due to the
error "Failed to activate virtual core keyboard: 2". The problem
is access violation in the code retrieving the pgid of the ctty.
This patch fixes the issue.
Mike Frysinger [Sat, 26 Feb 2022 04:47:03 +0000 (23:47 -0500)]
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.
Sebastian Huber [Wed, 9 Mar 2022 06:46:13 +0000 (07:46 +0100)]
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.
Mike Frysinger [Tue, 1 Mar 2022 05:30:46 +0000 (00:30 -0500)]
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.
Mike Frysinger [Tue, 1 Mar 2022 04:46:52 +0000 (23:46 -0500)]
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.
Takashi Yano [Fri, 4 Mar 2022 13:02:35 +0000 (22:02 +0900)]
Cygwin: pty: Fix a possible race issue in initialization of pcon.
- Currently, tty::pcon_start flag is cleared before transfer_input()
in master::write(), however, the code in setup_pseudoconsole()
waits for transfer_input() using tty::pcon_start. This possibly
causes the race issue. The patch fixes this potential issue.
Takashi Yano [Fri, 4 Mar 2022 09:54:18 +0000 (18:54 +0900)]
Cygwin: pty: Omit transfer_input() call where it is no longer needed.
- This patch removes the old code which calls transfer_input() but
is no longer needed. These code was necessary indeed in the past,
however, as a result of recent frequent code changes, it is no
longer needed.
- Previously, reset_switch_to_nat_pipe() is called from many places
in pty code. This patch reorganizes that. With this patch, it is
called only from bg_check() and setpgid_aux(). The calls which
does not have enough reason have been omitted.
Takashi Yano [Fri, 4 Mar 2022 07:05:35 +0000 (16:05 +0900)]
Cygwin: pty: Treat both CR and NL as line feed in transfer_inpup().
- To make read() work properly in canonical mode, writing to the pty
pipe should be done line by line. However, only CR was treated as
line separator previously in transfer_input(). This patch fixes
the issue.
Takashi Yano [Thu, 3 Mar 2022 02:43:07 +0000 (11:43 +0900)]
Cygwin: pty: Stop to use PID_NEW_PG flag as a marker for GDB.
- Previously, the PID_NEW_PG flag was also used as a marker for GDB
with non-cygwin inferior, unlike its original meaning. With this
patch, the condition exec_dwProcessId == dwProcessId is used as a
marker for that instead.
Cygwin: sysconf: don't set errno for unsupported options
We return -1 with errno set to EINVAL for sysconf options for
values required by POSIX, but not implemented on Cygwin.
This is incorrect. Return -1, but don't set errno for these options.
Drop the "nsup" enum to indicate unsupported values, it's not
required anymore.
Cygwin: sysconf: belatedly add correct return value for _SC_DELAYTIMER_MAX
When adding the timer_getoverrun function, DELAYTIMER_MAX was added
to limits.h, but the return value of sysconf(_SC_DELAYTIMER_MAX) wasn't
changed accordingly. Fix that now.
Takashi Yano [Wed, 2 Mar 2022 19:06:38 +0000 (04:06 +0900)]
Cygwin: pty: Add still missing acquire/release_attach_mutex.
- transfer_input() function uses console api, so it should be guarded
by attach_mutex. However, in most cases, it is missing. This patch
fixes the issue.
Takashi Yano [Wed, 2 Mar 2022 12:35:40 +0000 (21:35 +0900)]
Cygwin: pty: Communalize the code for temporary attach to console.
- This patch communalizes the code for attaching another console
temporarily and resuming to the original attach state, because
there were a plurality of similar codes throughout.
Takashi Yano [Wed, 2 Mar 2022 07:00:31 +0000 (16:00 +0900)]
Cygwin: console, pty: Revamp the acquire/release_attach_mutex timing.
- This patch revises the acquiring/releasing timing for attach_mutex
to make the period in which it is being acquired shorter. Further,
acquiring/releasing are added to where they are missing but needed.
Mike Frysinger [Tue, 1 Mar 2022 01:18:39 +0000 (20:18 -0500)]
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.
Takashi Yano [Tue, 1 Mar 2022 23:35:09 +0000 (08:35 +0900)]
Cygwin: console: Stop to create struct instance which is not needed.
- In fhandler_console::cons_master_thread(), a struct which has
only a static function is used. In this case, struct instance
is not necessary. So with this patch, the static function is
invoked without creating instance.
Takashi Yano [Tue, 1 Mar 2022 13:09:01 +0000 (22:09 +0900)]
Cygwin: pty: Rename some functions/variables with the name *pcon*.
- With this patch, some pty functions/variables have been renamed
so that the name *pcon* is not used for those that are called
even when the pseudo console is not active.
Takashi Yano [Tue, 1 Mar 2022 02:34:16 +0000 (11:34 +0900)]
Cygwin: pty: Avoid cutting the branch the pty master is sitting on.
- When Ctrl-C terminates a non-cygwin process on a pseudo console,
pty master attaches to the pseudo console first, and send
CTRL_C_EVENT. If the non-cygwin process closes the pseudo console
before the pty master calls FreeConsole(), the pty master process
will crash. With this patch, pty master process takes over the
ownership of the pseudo console, and closes it by myself.
Mike Frysinger [Sat, 19 Feb 2022 05:54:20 +0000 (00:54 -0500)]
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.
Mike Frysinger [Fri, 25 Feb 2022 04:43:06 +0000 (23:43 -0500)]
libgloss: add a little build system generation documentation
This is a bit of an abbreviated form of what's in the Newlib subdir,
but with emphasis on Libgloss-specific parts, and anything unique to
it. I haven't put too much effort in.
Mike Frysinger [Sat, 26 Feb 2022 04:17:42 +0000 (23:17 -0500)]
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.
Mike Frysinger [Sat, 19 Feb 2022 05:22:14 +0000 (00:22 -0500)]
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.
Takashi Yano [Mon, 28 Feb 2022 11:25:09 +0000 (20:25 +0900)]
Cygwin: pty: Isolate CTRL_C_EVENTs between ptys.
- With this patch, unique invisible consoles are created for each pty
to isolate CTRL_C_EVENTs between ptys. This is necessary by Ctrl-C
handling in fhandler_termios::process_sigs() for non-cygwin apps
started in pty if the pseudo console is disabled.
Takashi Yano [Mon, 28 Feb 2022 11:02:01 +0000 (20:02 +0900)]
Cygwin: console: Improve the code to avoid typeahead key swapping.
- The commit "Cygwin: console: Prevent the order of typeahead input
from swapped." did not fully resolve the issue. If keys are typed
during input buffer fix, the order of key event may be swapped.
This patch fixes the issue again.
Takashi Yano [Sat, 26 Feb 2022 06:13:13 +0000 (15:13 +0900)]
Cygwin: pinfo: Fix exit code for non-cygwin apps which reads console.
- The recent commit "Cygwin: pinfo: Fix exit code when non-cygwin app
exits by Ctrl-C." did not fix enough the issue. If a non-cygwin app
is reading the console, it will not return STATUS_CONTROL_C_EXIT
even if it is terminated by Ctrl-C. As a result, the previous patch
does not take effect.
This patch solves this issue by setting sigExeced to SIGINT in
ctrl_c_handler(). In addition, sigExeced will be cleared if the app
does not terminated within predetermined time period. The reason is
that the app does not seem to be terminated by the signal sigExeced.
Takashi Yano [Sun, 27 Feb 2022 03:33:08 +0000 (12:33 +0900)]
Cygwin: console: Correct the past fix for apps which open pty.
- The commit "Cygwin: console: Fix issues of apps which open pty."
did not fix the second problem correctly. That commit looked to
fix the issue, but the actual problem was that ctrl_c_handler()
should be reregistered *AFTER* FreeConsole()/AttachConsole().
This patch correct that.
- The commit "Cygwin: console: Restore CTRL_BREAK_EVENT handling."
was accidentally mixed with experimental code in exceptions.cc.
Due to this, non-cygwin app receives CTRL_C_EVENT twice in the
following scenario.
1) Run 'sleep 10 | <non-cygwin app>'
2) Hit Ctrl-C.
3) The non-cygwin app receives CTRL_C_EVENT twice.
This patch reverts the code with the problem.
Takashi Yano [Fri, 25 Feb 2022 08:10:03 +0000 (17:10 +0900)]
Cygwin: console: Prevent the order of typeahead input from swapped.
- If a lot of keys are typed very quickly in the app which does
not read console, the order of input keys in console input buffer
occasionally swapped. Although this extremely rarely happens,
is obviously a bug of cons_master_thread. This patch fixes the
issue.
Takashi Yano [Fri, 25 Feb 2022 19:19:03 +0000 (04:19 +0900)]
Cygwin: pty: Stop to send CTRL_C_EVENT if pcon activated.
- The commit "Cygwin: console: Redesign handling of special keys."
removes special treatment for pty in with pseudo console activated,
however, it is necessary on second thought. This is because sending
CTRL_C_EVENT to non-cygwin apps will be done in pseudo console,
therefore, sending it in fhandler_pty_master::write() duplicates
that event for non-cygwin apps.
Takashi Yano [Fri, 25 Feb 2022 07:23:58 +0000 (16:23 +0900)]
Cygwin: console: Fix issues of apps which open pty.
- After some recent changes for special keys handling break the
apps which open pty (such as script command). If the app which
opens pty is executed in console, the following issues occur.
1) If the script command was started from non-cygwin shell
(such as cmd.exe), another cygwin app started in pty slave
cannot receive Ctrl-C.
2) If non-cygwin app is executed in pty slave, the app which
opened the pty (e.g. script command) crashes by Ctrl-C.
This patch fixes these issues.
Mike Frysinger [Sat, 12 Feb 2022 10:36:20 +0000 (05:36 -0500)]
libgloss: switch to AM_PROG_AR
Now that we require Automake 1.15, we can use this macro rather than
set the tool up ourselves. The current code doesn't properly search
for a prefixed ar tool as-is.
Mike Frysinger [Sun, 13 Feb 2022 00:49:23 +0000 (19:49 -0500)]
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.
Takashi Yano [Thu, 24 Feb 2022 12:04:49 +0000 (21:04 +0900)]
Cygwin: pinfo: Fix exit code when non-cygwin app exits by Ctrl-C.
- Previously, if non-cygwin app exits by Ctrl-C, exit code was
0x00007f00. With this patch, the exit code will be 0x00000002,
which means process exited by SIGINT.
The multi-build.in file in libgloss duplicates common multilib logic
in the root source tree. Document it a bit, and rename the rule so
it doesn't clash with the common multi-do rule. This will let us use
them in the same makefile so we can merge aarch64/ & arm/ up (as the
only targets that use this local multi-build.in atm).
Mike Frysinger [Sat, 19 Feb 2022 04:46:44 +0000 (23:46 -0500)]
libgloss: finish migration to AM_PROG_AS
When merging iq2000 up a level, it included a partial conversion to
AM_PROG_AS in the common directory. Finish it for all directories
to kill off the custom LIB_AM_PROG_AS which we no longer need since
we require Automake 1.15 now.
Mike Frysinger [Sat, 12 Feb 2022 10:29:06 +0000 (05:29 -0500)]
libgloss: 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.
Takashi Yano [Thu, 24 Feb 2022 08:28:32 +0000 (17:28 +0900)]
Cygwin: console: Restore CTRL_BREAK_EVENT handling.
- The recent change by the commit "Cygwin: console: Redesign handling
of special keys." breaks the handling of CTRL_BREAK_EVENT. The login
shell in console exits on Ctrl-Break key. This patch fixes the issue.
Mike Frysinger [Thu, 24 Feb 2022 03:01:05 +0000 (22:01 -0500)]
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 f2b053f49ed2bd7b4da8cf4ed3a608dc2f425c2b ("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.
Takashi Yano [Wed, 23 Feb 2022 15:57:37 +0000 (00:57 +0900)]
Cygwin: pty, console: Add a workaround for GDB SIGINT handling.
- The inferior of the GDB cannot be continued after SIGINT even
though nopass option is set. This seems because cygwin GDB does
not support hooking cygwin signal. Therefore, a workaround for
GDB is added. With this patch, only CTRL_C_EVENT is sent to the
GDB inferior by Ctrl-C and sending SIGINT is omitted. Note that
"handle SIGINT (no)pass" command does not take effect even with
or without this patch.
Takashi Yano [Wed, 23 Feb 2022 04:24:39 +0000 (13:24 +0900)]
Cygwin: console: Redesign handling of special keys.
- This patch rearranges the cooperation between cons_master_thread,
line_edit, and ctrl_c_handler so that only one of them operates
at the same time. Since these handle Ctrl-C individually, so the
signal may be sent multiple times to the process. This patch fixes
the issue.
Mike Frysinger [Tue, 22 Feb 2022 22:09:16 +0000 (17:09 -0500)]
libgloss: enable maintainer mode support
Use AM_MAINTAINER_MODE so devs have to opt-in to automatic rebuilds
of autotools. This matches what newlib (and most every other GNU
toolchain package) does with automake.
Cygwin: Implicitly support the /dev/fd symlink and friends
Bash has a very convenient feature that is called process substitution
(e.g. `diff -u <(seq 0 10) <(seq 1 11)`). To make this work, Bash
requires the `/dev/fd` symlink to exist, and Cygwin therefore creates
this symlink (together with the `stdin`, `stdout` and `stderr` ones)
upon start-up.
This strategy is incompatible with the idea of providing a subset of
Cygwin in a `.zip` file (because there is no standard way to represent
symlinks in `.zip` files, and besides, older Windows versions would
potentially lack support for them anyway).
That type of `.zip` file is what Git for Windows wants to use, though,
bundling a minimal subset for third-party applications in MinGit (see
https://github.com/git-for-windows/git/wiki/MinGit for details).
Let's side-step this problem completely by creating those symlinks
implicitly, similar to the way `/dev/` is populated with special
devices.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Matt Joyce [Tue, 22 Feb 2022 10:18:38 +0000 (11:18 +0100)]
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.
Takashi Yano [Mon, 21 Feb 2022 12:20:48 +0000 (21:20 +0900)]
Cygwin: pty, console: Fix handle leak which occurs on exec() error.
- This patch fixes the handle leak which occurs when exec() fails
with an error. The duplicated handles will be closed when the
exec'ed process is terminated. However, if exec() fails, the code
path does not reach to the code closing the duplicated handles.
To implement this fix more appropriately, the setup, cleanup and
closing pty codes which was previously located in spawn.cc are
encapsulated into the fhandler_pty_slave class functions.
Takashi Yano [Wed, 16 Feb 2022 15:34:40 +0000 (00:34 +0900)]
Cygwin: console: Call fix_tab_position() only if having broken tabs.
- Calling fix_tab_position() is necessary in Windows 10 with xterm
compatible mode enabled, because it has a problem that the tab
positions will be broken when the window size is changed. Fortunately,
this problem has been fixed in Windows 11. Therefore, with this patch,
necessity of fix_tab_position() call is determined by referring to
wincap.has_con_broken_tabs(), which is recently introduced.
- With this patch, all set_(in|out)put_mode() calls are rearranged
as follows.
1) Setup for cygwin apps, started from non-cygwin app, is done
in fhandler_console::post_open_setup(), which overrides
fhandler_base::post_open_setup() called from dtable.cc.
2) Cleanup for cygwin app is done in fhandler_console::close().
3) Setup for cygwin apps is also in fhandler_console::bg_check(),
which overrides fhandler_termios::bg_check(). This is called
on read(), write() and select() for console. It is necessary
if cygwin and non-cygwin apps are started simultaneously in
the same process group.
4) Setup for non-cygwin apps is done in spawn.cc via
fhandler_console::setup_console_for_non_cygwin_app().
5) Cleanup for non-cygwin app is done in spawn.cc vid
fhandler_console::cleanup_console_for_non_cygwin_app().
6) Setup for non-cygwin app started by GDB is done in
fhandler_console::set_console_mode_to_native().
7) No explicit cleanup for non-cygwin app started by GDB, because
console mode is automatically reset to tty::cygwin on read()/
write() in GDB thanks to 3).
Takashi Yano [Tue, 15 Feb 2022 14:23:50 +0000 (23:23 +0900)]
Cygwin: pty, console: Refactor the code processing special keys.
- This patch commonize the code which processes special keys in pty
and console to improve maintanancibility. As a result, some small
bugs have been fixed.
Mike Frysinger [Sun, 13 Feb 2022 01:28:26 +0000 (20:28 -0500)]
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.
Mike Frysinger [Sun, 13 Feb 2022 10:43:42 +0000 (05:43 -0500)]
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).
Mike Frysinger [Thu, 10 Feb 2022 05:50:36 +0000 (00:50 -0500)]
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.
Mike Frysinger [Sun, 13 Feb 2022 08:03:12 +0000 (03:03 -0500)]
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.
Mike Frysinger [Sun, 13 Feb 2022 07:44:31 +0000 (02:44 -0500)]
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.
Mike Frysinger [Tue, 15 Feb 2022 02:37:38 +0000 (21:37 -0500)]
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.