Bug 236662 - devel/arm-none-eabi-newlib breaks gcc
Summary: devel/arm-none-eabi-newlib breaks gcc
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Kyle Evans
Depends on:
Reported: 2019-03-20 12:36 UTC by Christopher Hall
Modified: 2020-06-16 22:51 UTC (History)
3 users (show)

See Also:

Attempt to update to gcc-8.3 (9.24 KB, patch)
2019-05-28 06:06 UTC, Christopher Hall
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Hall 2019-03-20 12:36:34 UTC
after install of the install arm-none-eabi-newlib arm-none-eabi-gcc cannot compile C sources.

starting with only the compiler (no newlib installed stub program is ok, but after installing newlib compileing stdio.h fails with many errors.

% cat main.c
#include <stdio.h>

int main(int argc, char*argv[]) {
	return 2;

% arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb  main.c -o main.o

% doas pkg install -y arm-none-eabi-newlib
All repositories are up to date.
Checking integrity... done (0 conflicting)
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
	arm-none-eabi-newlib: 2.4.0_1

Number of packages to be installed: 1

The process will require 9 MiB more space.
[1/1] Installing arm-none-eabi-newlib-2.4.0_1...
[1/1] Extracting arm-none-eabi-newlib-2.4.0_1: 100%

% arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb  main.c -o main.o
In file included from main.c:1:0:
/usr/local/lib/gcc/arm-none-eabi/6.4.0/include-fixed/stdio.h:61:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'typedef'
 typedef __off_t  fpos_t;
/usr/local/lib/gcc/arm-none-eabi/6.4.0/include-fixed/stdio.h:61:9: error: unknown type name '__off_t'
 typedef __off_t  fpos_t;
/usr/local/lib/gcc/arm-none-eabi/6.4.0/include-fixed/stdio.h:76:9: error: unknown type name '__off_t'
 typedef __off_t  off_t;
/usr/local/lib/gcc/arm-none-eabi/6.4.0/include-fixed/stdio.h:80:9: error: unknown type name '__ssize_t'
 typedef __ssize_t ssize_t;
/usr/local/lib/gcc/arm-none-eabi/6.4.0/include-fixed/stdio.h:86:9: error: unknown type name '__off64_t'
 typedef __off64_t off64_t;
/usr/local/lib/gcc/arm-none-eabi/6.4.0/include-fixed/stdio.h:91:9: error: unknown type name '__va_list'
 typedef __va_list __not_va_list__;
/usr/local/lib/gcc/arm-none-eabi/6.4.0/include-fixed/stdio.h:149:19: error: expected ')' before '_close'
  int (* _Nullable _close)(void *);
Comment 1 Christopher Hall 2019-03-20 12:40:20 UTC
I tried to update the arm-none-eabi-gcc to 7.4.0 and then 8.3.0 but having nelib installed breaks these.

If i rename /usr/local/arm-none-eabi/include to prevent the compiler finding the newlib  headers then compile and port build works again.  Seems like the headers installed by newlib are broken in some way.
Comment 2 Christopher Hall 2019-04-03 00:45:00 UTC
Just in case anyone is trying to use arm-non-eabi-* to compile STM32 code
don't, use the gcc-arm-embedded and add it to your PATH it works correctly.  This newlib is not compatible with thumb code.
Comment 3 Remy Nonnenmacher 2019-05-03 08:25:17 UTC
I confirm. arm-none-eabi-gcc492 and gcc-arm-embedded work but not default (6.4) version.
Comment 4 dvma 2019-05-26 01:21:22 UTC
(In reply to Christopher Hall from comment #1)
Hi Christopher Hall ~

could you tell me how to update it to arm-none-eabi-gcc 7.4.0?
Comment 5 Christopher Hall 2019-05-27 01:18:32 UTC
I only tried updateing to 8 and you had to update in the powerpc port, I am not at the computer where i tried this, so cannot check exactly, but I remember the main problem was that none of the patches in the powerpc base port applied.  Mostly this was a lot of whitespace changes in the files, but I do not think there was any real problem than just updating to 8.x (I might have used the same as devel/arm-gcc-embedded)

I'll take a look later on the other machine to see what I can find.
Comment 6 Christopher Hall 2019-05-28 06:06:27 UTC
Created attachment 204661 [details]
Attempt to update to gcc-8.3

This is a diff between the ports as I had them during my attemp to update the ARM gcc to 8.3 and the current state of ports as just updated by portsnap
Comment 7 Christopher Hall 2019-05-28 06:08:22 UTC
(In reply to dvma from comment #4)
I added a patch to replicate my 8.3 update fixes, if I remember correctly you ought to be able to get 7.x to work by changing the makefile version.
Comment 8 Li-Wen Hsu freebsd_committer 2020-06-16 22:51:41 UTC
Over to maintainer.