Avoid a recursive make to speed things up a bit.
A i386-elf build shows installed objects & libs produce same code other
than a rename from cygmon-gmon.o & cygmon-salib.o to i386_libcygmon_a-*.o
due to the use of custom CPPFLAGS in here.
This was added to specify -Wa,-gdwarf2 when compiling the assembly
files. Considering the size of these .S files, it seems unnecessary
overkill and complicates the build system. All but one of these
compile down to 6 or fewer lines, and those hardly need extra debug
for anyone who is poking msp430 assembly. The 1 file that is larger
than that (crt_move_highdata.S) is still <15 insns.
This will also simplify merging it into the top-level Makefile.
The build system compiles crt0.S many times to produce independent
object files by defining different -DLxxx symbols for each. This
complicates the build, and has led to some bugs in the source and
build (see the previous cleanup commits in here). The crt_bss.S
file has also been duplicated with crt0.S leading to confusion as
to which one is the "real" one. The only reason to keep them in
one file is to make management of the section numbers when calling
START_CRT_FUNC a little easier, but that seems trivial to check
with a quick grep across all the files.
Considering how complicated the build is now, and the bugs we've
had as a result, split the crt0.S file up into multiple source
files so we don't have to compile it multiple times. This will
also simplify merging it into the top-level Makefile.
This object is created by compiling crt0.S with -DLinit, but there
has never been an "#if Linit" check in crt0.S, so this has always
produced a stub object file. Drop compiling it entirely.
The #if 0 & comment imply this code doesn't exist and is never used,
except there's another #if Lrun_fini_array section below which *does*
define this function, which makes this code comment confusing. This
seems to be a hold over of the cleanup of the minrt code in the old
commit 884b05b54e ("MSP430: Remove
.init/.fini sections").
This logic is copied from what's used in newlib today. This allows
subdirs to easily define per-directory flags & per-file flags without
having to setup unique automake rules for each one.
A bunch of ports have manual rules to generate disassembly, srec, and
binary files from test programs. Add top-level pattern rules so every
test program gets this for free, and we don't have to duplicate it in
every subdir.
Currently init_semihosting() assumes the return value from _open()
call as the file descriptor handle and that is incorrect.
The semihost _open() call returns the fdtable index returned by the
__add_fdentry() for the file opened.
Set symbol '__jvt_base$' as weak. So if the symbol is not set in the
linker script, the address would be 0. We initialize jvt CSR only if
the address is not 0.
Also use csr number directly instead of using symbolic name to prevent the
backward incompatible issue.
psabi reference:
2d770815dc/riscv-elf.adoc (table-jump-relaxation)
The i960 port has a lot of references to sim files that have never been
included in the tree afaict, and thus has never worked. Delete all the
code to simplify.
This is a .c file, not assembly, and it's a duplicate (same content)
as the existing sim-lseek.c. Delete it since it's unused and doesn't
actually compile.
Similar to what's been done in the ports, but this time in generic code.
Add missing #includes to pick up prototypes. Add prototypes for various
internal functions where needed. Fix signatures of various functions to match
what's provided by the headers (read, sbrk, write, unlink).
Nearly done with this effort ;-)
Pushed to the trunk,
I guess I must have missed this when working through the trivial port specific
changes.
This adds an include of stdlib.h to get a prototype for exit().
Pushed to the trunk.
Commit 8d75828378 ("libgloss: merge
sparc configure script up a level") missed including the sparc
acinclude.m4 file which meant none of the sparc-specific vars were
propagating to the sub-makefile.
So in this case we mostly need to include an internal header
(epiphany-syscalls.h). In a few cases an explicit prototype is added. We've
also got a return with no value in a function with a non-void return type.
Finally the asm_syscall interface expects a pointer as its first argument. In
a few cases we've actually got an int (file descriptor) which we just cast to a
void *.
It's slightly more than Jeff J's pre-approval, but I think still reasonable.
Make implicit its explicit, add missing prototypes and header includes. This
does not fix m32r-stub.c which needs more than the trivial work that Jeff J has
pre-approved.
So the prior patch for sysnecv850 was in newlib. This time we're fixing v850
bits in libgloss.
Like other patches submitted recently, this converts implicit ints to explicit
ints, adds a missing prototype and header includes.
By default, only split node html manuals are generated. Change the
default to single page, and add an extra rule to also generate the
split page manual.
Since $(AS) is the assembler, passing it a list of preprocessor include
flags doesn't make much sense. The files aren't preprocessed which means
`#include` lines aren't respected, and while it would affect `.include`
usage, we never use that, and it's extremely unlikely to change. Plus,
it's extremely unlikely we'd have .s files in common places to include vs
contained entirely within a specific arch dir, and at that point, it can
be included directly (with no flags), or the arch can add the unique set
of include paths that it needs for itself.
This reverts commit 17ac400c11.
The build failures were due to incorrectly using $(INCLUDES) when
running $(AS). Let's roll this back and drop $(INCLUDES) from the
$(AS) invocations.
gcc-14 will complain loudly both for calling a function without an in-scope
prototype or when the in scope prototype differs from the known signature.
"main" happens to be one of the functions the compiler knows about. So not
only do we need to prototype it, we need to make sure the prototype matches
what GCC thinks it should be.
This fixes the bfin libgloss port to do the right thing for bfin-elf.
Two libgloss issues specific to moxie-elf that show up build with GCC trunk.
First, putnum.c uses "print" without a prototype. So I added one based on the
function's definition in print.c. Second sim-inbyte.c uses read, which comes
from unistd.h, so this adds a suitable #include.
gcc-14 will default to c99 and as a result a fair amount of old code in newlib
(particularly libgloss) is failing to build. I don't offhand know how many
patches will be necessary to fix the various failures. I'll just pick them off
one by one from my tree.
This particular patch works around the return-mismatch problem syscalls.c for
fr30.
That file is a bit odd in that most functions are declared as returning an
integer, but the implementations look like:
> int
> _read (file, ptr, len)
> int file;
> char * ptr;
> int len;
> {
> asm ("ldi:8 %0, r0" :: "i" (SYS_read) : "r0");
> asm ("int #10");
>
> return;
> }
Note the lack of a value on the "return" statement. The assumption is that the
interrupt handler implementing syscalls will put the return value into the
proper register, so falling off the end of the C function or returning with no
value works in the expected way. It's not good code, but it probably works.
Working from that assumption I decided to just use a pragma to disable the
upgraded diagnostic from GCC -- essentially preserving existing behavior.
This is the only fr30 specific issue that needs to be resolved and the only
issue (so far) I've seen of this specific nature.
This is the libgloss part.
Recently, there was a change in gcc such that implicit function
declarations and type mismatches are now errors, no longer just
warnings. Fix by adding and correcting declarations warned about;
including the right header or adding a declaration (for "main" in
lcrt0.c) and adjust to those types as necessary.
Upstream GCC has change this warning into error by default, so...we need
to explicitly convert the type from pointer from/to integer, generally
it's unsafe, but we know what we are doing here.
However it's not safe for ilp32 on RV64, but we didn't support that yet, so I
think this fix is good enough now :)
Replace multiplication with division for microseconds calculation from
nanoseconds in _gettimeofday function.
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Example test case that fails with undefined reference to getentropy:
Testing g++.robertl/eb77.C, -std=c++20
doing compile
Executing on host: /build/gcc-13-2709-g9ac9fde961f/bin/arm-none-eabi-g++ /build/src/gcc/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C -mthumb -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft -fdiagnostics-plain-output -fmessage-length=0 -std=c++20 -pedantic-errors -Wno-long-long -Wl,--start-group -lc -lm -Wl,--end-group --specs=nosys.specs -Wl,--allow-multiple-definition -Wl,-u,_isatty,-u,_fstat -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort -Wl,g++_tg.o -lm -o ./eb77.exe (timeout = 800)
spawn -ignore SIGHUP /build/gcc-13-2709-g9ac9fde961f/bin/arm-none-eabi-g++ /build/src/gcc/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C -mthumb -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft -fdiagnostics-plain-output -fmessage-length=0 -std=c++20 -pedantic-errors -Wno-long-long -Wl,--start-group -lc -lm -Wl,--end-group --specs=nosys.specs -Wl,--allow-multiple-definition -Wl,-u,_isatty,-u,_fstat -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort -Wl,g++_tg.o -lm -o ./eb77.exe
pid is 28414 -28414
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): in function `std::(anonymous namespace)::__libc_getentropy(void*)':
(.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined reference to `getentropy'
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): in function `std::random_device::_M_init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
(.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58): undefined reference to `getentropy'
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-arc4random.o): in function `_rs_stir':
(.text._rs_stir+0x8): undefined reference to `getentropy'
collect2: error: ld returned 1 exit status
pid is -1
close result is 28414 exp6 0 1
output is /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): in function `std::(anonymous namespace)::__libc_getentropy(void*)':
(.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined reference to `getentropy'
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): in function `std::random_device::_M_init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
(.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58): undefined reference to `getentropy'
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-arc4random.o): in function `_rs_stir':
(.text._rs_stir+0x8): undefined reference to `getentropy'
collect2: error: ld returned 1 exit status
status 1
compiler exited with status 1
FAIL: g++.old-deja/g++.robertl/eb77.C -std=c++20 (test for excess errors)
Excess errors:
(.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined reference to `getentropy'
(.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58): undefined reference to `getentropy'
(.text._rs_stir+0x8): undefined reference to `getentropy'
UNRESOLVED: g++.old-deja/g++.robertl/eb77.C -std=c++20 compilation failed to produce executable
Contributed by STMicroelectronics
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
If a CPU implements EL2 as its highest exception level then programs
using newlib may start in hypervisor mode. In that state it is not
trivial to switch into the various EL1 modes to configure the
individual exception stacks, so do not try.
The libgloss port has been reaching back into newlib internals for a
single header whose contents have been frozen for almost a decade.
To break this backwards libgloss->newlib dependency, move the acle
header to the srcroot include/ so everyone can use the same copy.
Since no other port uses this custom libgloss multi-build.in logic,
and it's making things difficult to unify, drop it all. The set of
installed objects and their content should be the same.
There is a difference in the builds: currently we compile all the
objects in this subdir twice, but only a subset of them use a diff
set of flags, and are actually installed (the librdimon.a and its
objects). So this change speeds things up by removing the duplicate
compilation.
There is a short term cost in having to duplicate the compile rules
for the files that are different, but this is minor when compared to
being able to delete the unused multi-build logic (which we'll do in
a sep commit), and we'll be able to clean this up when we move the
code to unified automake.
None of this should be confused with the common multilib logic.
This is *multi-build* which is processed in parallel.
This logic looks like it was copied from the arm port, but it isn't
actually used here. Since no other port uses this custom libgloss
multi-build.in logic, and it's making things difficult to unify,
and aarch64 isn't even using it, drop it all. The set of installed
objects and their content should be the same.
Once we move this to unified automake, if we want to readd support
for subdir multi-builds, it'll be a lot easier as we can just add
another set of objects with custom flags.
None of this should be confused with the common multilib logic.
This *multi-build* which is processed in parallel.
A recent change to the Makefile.in for riscv resulted in the
machine/syscall.h header not being installed. This updates the file
to install this file again.
Signed-off-by: Simon Cook <simon.cook@embecosm.com>
PR 29515 points out our documentation builds are broken, let's just move
over to the new non-recursive builds.
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
For the exit processing only members of _GLOBAL_REENT were used by default. If
the _REENT_GLOBAL_ATEXIT option was enabled, then the data structures were
provided through dedicated global objects. Make this option the default.
Remove the option. Rename struct _reent members _atexit and _atexit0 to
_reserved_6 and _reserved_7, respectively. Provide them only if
_REENT_BACKWARD_BINARY_COMPAT is defined.
The _open() C function is declared as having variable arguments in
newlib, so second and third arguments are passed on stack. Add code to
move them into registers, since that's where the PRU simulator expects
them.
Issue was exposed by the GCC test gcc.c-torture/execute/fprintf-2.c,
which relies on tmpnam implementation to pass correct flags to _open.
Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
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.
Avoid a recursive make to speed things up a bit.
This drops the header install logic because the lm32/ subdir doesn't
actually have any header files to install.
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.
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.
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).
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.
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.
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.
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.
Move the minor wince-specific logic to a dedicated file & namespace
them so we can merge its configure logic up a level. The makefile
is a bit tricky, but maybe it still works.
We don't want libgloss building against C library headers that happened
to be installed with the toolchain, so add -nostdinc to the build. We
still need access to the compiler internal headers, so probe those and
include them via -isystem. This uses a similar probing style as glibc,
which has used it for over a decade, so it should be safe & stable.
This should prevent any latent bugs due to testing with a toolchain that
is fully configured & installed already.
The cpu-init/configure script isn't doing anything useful, so merge
the logic up to the parent dir. This is how the arm/ tree integrates
its cpu-init/ subdir too.
Move the minor mn10300-specific logic to a dedicated file & namespace
them so we can merge its configure logic up a level. part_specific_obj
wasn't used anywhere (looks like copy & paste left over from mips), so
drop it entirely.
The mn10200-specific logic (setting up part_specific_obj) isn't used
by the build anywhere -- looks like copy & paste left overs from mips.
So punt that & merge the target_makefile_frag_path up to the top-level.