www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2016/04/20/18:24:31

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
Message-ID: <5717FF70.3020801@gmx.de>
Date: Thu, 21 Apr 2016 00:15:12 +0200
From: "Juan Manuel Guerrero (juan DOT guerrero AT gmx DOT de) [via djgpp-workers AT delorie DOT com]" <djgpp-workers AT delorie DOT com>
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.13) Gecko/20101206 SUSE/3.1.7 Thunderbird/3.1.7
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
Subject: Re: Test build of gcc-6.0.1-20160415
References: <5713789D DOT 8070708 AT iki DOT fi> <57152494 DOT 6040808 AT gmx DOT de> <57154DC1 DOT 2080907 AT iki DOT fi>
In-Reply-To: <57154DC1.2080907@iki.fi>
X-Provags-ID: V03:K0:j+sgOjVsd9ob7eypYjZVaA5d55TsEDsnpJKZWCAVBmkegGt/sws
qRr70eb9zbtFjisPhbi1XL77/kZRn/6twV1Bu3AX111M7/VBV+Zv7JYdotNBKQCBuJZ7CnO
n3DrJcMXziVjn8Z3+/+d06M0foQceCoxgC9tOdJvmPnWj61LIKXzyZLVrLFj0qa4W4o9HEW
/t4rFNxop0B3t0Efb2daA==
X-UI-Out-Filterresults: notjunk:1;V01:K0:L4jIJbbHsWM=:Uke9VP5DaZfheZIIb1Kzk/
Pun/y2Qek3oZ3YXwf9jHugR3hTeKGsVgzcYBad3R0PpDt3A0j4WOcMy4XZj0G0ndGCCQLNSGA
KIkh5EMvTbFYfcodoSpAY3cHzLx3DWQbNjoaks7Q7GvHHvLHoRSWvQkOj7AyfMA0ax9Qbcnlw
tFlhvKwVjOXGnvMd1qCGkTgl0Ke3CMdsIunyEf+mrN60AJ/9oSMzUzxL127JYlYd2UcAaTzwk
7b/g5RrpEniThdMAttB6dypYPWDBF1V4iV7QlreWtbIhzGDPo0BsIscUgFAkSQysoKXEH7n4p
fzYSl0ViZHY8ddAZZbKHROlg3QB9agK0xfu7j9D/mFNyKjzF2xsbsIdLbLk5XGToEidNAUfvE
gg1EYEV/EZHTczCx/XCJknrR/SwtBwTYdinExw1X8BOVGlJgnlB7gQwbKIrgZmNMWy+2TLXnS
AHtHrkwAXxhHw3QXGZk3KGkVO61wmyVy05BDQdNE7D+tXv479jO+WeBqepW10xw6opTusaxyH
Ia4deAiPoRpsd06nstic2BYD57EMbfvFJna16MSevZRc4k1/zxL08rbmSyifE0i1Vl6QKPYL2
8sO/IUlrHnnLWs+ftZCkeUbkeGhtk4oMK+luBiX2N04ZUMmGMlho0Iq0RiMDdTSJznaWbKpCz
CSs+RQcQhUGkE9989cf8v5FAdMUGTTCx4zQ5FQC2AygRdWQnJa/nngUjOZ/eayegwGZBoC6d5
BXKyfIul9UJ16D5YI9WoAPow1OVEFd/p0d9SF7quXa8NKPEruF0ZQGh+NBCenI/AjAIibp8dP
z0S/uRm
Reply-To: djgpp-workers AT delorie DOT com

Am 18.04.2016 23:12, schrieb Andris Pavenis (andris DOT pavenis AT iki DOT fi) [via djgpp-workers AT delorie DOT com]:
> On 04/18/2016 09:16 PM, Juan Manuel Guerrero (juan DOT guerrero AT gmx DOT de) [via djgpp-workers AT delorie DOT com] wrote:
>> Am 17.04.2016 13:50, schrieb Andris Pavenis (andris DOT pavenis AT iki DOT fi) [via djgpp-workers AT delorie DOT com]:
>>> gcc-6.1.0 should not be very far any more:
>>>
>>> https://gcc.gnu.org/ml/gcc/2016-04/msg00103.html
>>> https://gcc.gnu.org/ml/gcc/2016-04/msg00109.html
>>>
>>> I built DJGPP port based on SVN revision r235040 (the same used for release candidate sources) checked out from git mirror (see https://gcc.gnu.org/wiki/GitMirror for details). Of course DJGPP related additional changes are merged.
>>>
>>> Files (both i686 and x86_64 rpms and native DJGPP build are available for testing at:
>>>
>>> http://ap1.pp.fi/djgpp/gcc/test/6.0.1-20160415/
>>>
>>> Andris
>>>
>>
>>
>> I have tried to build libc from repository using g[cc|pp]601_20160415b.zip.
>> It fails with the following error message:
>>
>> gcc ... -c strlen.c
>> strlen.c: In function 'strlen':
>> strlen.c:10:6: error: nonnull argument 'str' compared to NULL [-Werror=nonnull-compare]
>> if (str == NULL)
>> ^
>> cc1.exe: all warnings being treated as errors
>> ../../../makefile.inc:89: recipe for target 'strlen.o' failed
>> make.exe[3]: *** [strlen.o] Error 1
>> makefile.sub:2: recipe for target 'all_subs' failed
>> make.exe[2]: *** [all_subs] Error 2
>> ../makefile.lib:6: recipe for target 'all' failed
>> make.exe[1]: *** [all] Error 2
>> makefile:39: recipe for target 'subs' failed
>> make.exe: *** [subs] Error 2
>>
>> Inspecting the strlen code, it is clear that the offending code segment is:
>>
>> if (str == NULL)
>> return 0;
>>
>> It seems to be that for some reason, the compiler does assume that the passed
>> argument to the function can never be NULL. If I understood correctly, this
>> should only be the case if the function is specified like this:
>>
>> size_t strlen(const char *_s) __attribute__ ((__nonnull__ (1)));
>>
>> specifying that _s is never NULL, but this is certainly not the case in the
>> current versions of string.h.
>>
>> So the question arises if we have to remove all NULL pointer check from our
>> code and if this measure is really wise? IMHO, we should adjust the compiler
>> checks in such a way that NULL pointer checks are still possible.
>> BTW I have inspected http://pubs.opengroup.org/onlinepubs/009695399/functions/strlen.html
>> and I have seen no indication that a NULL pointer check is prohibited, but
>> also I have seen no indication that a NULL pointer check is allowed.
>>
> GCC new versions are known to be too wise for its own good when it commes to builtin functions.
>
> We have already had similar problem with cmalloc() in nmalloc.c where GCC infinite wisdom told it to recognize source as implementation of __builtin_cmalloc() and over-optimize it to infinite tail recursion. Specifying -fno-builtin-cmalloc for nmalloc.c work-arounded the problem then (present in DJGPP v2.05). See:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67618
>
> (it was NOT DJGPP specific and could easily be reproduced on Linux)
>
> It seems that gcc current version recognizes DJGPP implementation of strlen as __builtin_strlen and assumes that __builtin_strlen should never have passed NULL argument with following messages.
> Specifying
>
> strlen.o: EXTRA_CFLAGS += -fno-builtin-strlen
>
> in src/libc/ansi/string/makefile causes error to disappear.
>
> Same problem with:
>
> libc/c99/math/nan*.c
> libc/compat/string/stpcpy.c
> libc/compat/string/stpncpy.c
> libc/compat/string/strdup.c
>
> and more (same approach as with strlen() works also for these).
>
> There are also other warnings interpreted as errors. Some examples:
>
> i586-pc-msdosdjgpp-gcc -pipe ... -c k_rem_pio2.c
> k_rem_pio2.c: In function '__kernel_rem_pio2':
> k_rem_pio2.c:190:6: error: this 'for' clause does not guard... [-Werror=misleading-indentation]
> for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
> ^~~
> k_rem_pio2.c:190:54: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'for'
> for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
> ^
> cc1: all warnings being treated as errors
>
> i586-pc-msdosdjgpp-gcc -pipe ... -c s_scalbn.c
> s_scalbn.c:69:1: error: 'huge' defined but not used [-Werror=unused-const-variable=]
> huge = 1.0e+300,
> ^~~~
> cc1: all warnings being treated as errors
>
> And some similar...
>
> I'm not going to fix these now immediately (in late evening).
>
> About -Wmisleading-indentation: I guess it would be best to disable it for gcc-6+
>
> Andris
>


The patch below is a proposition how the -Werror=nonnull-compare issue could be
handled.  The patch has intentionaly not been committed because there may be
multiple ways to fix this issue.  I have intentionaly prefered the way using
all the different -fno-builtin-* flags.  This way we see about what we are
warned and what we are intentionaly ignoring.  I have no preferences and if
someone else disigns a smarter or different fix, feel free to discard this
approach.


Regards,
Juan M. Guerrero



2016-04-20  Juan Manuel Guerrero <juan DOT guerrero AT gmx DOT de>

	* djgpp/src/makefile.cfg:  Fixing -Werror=nonnull-compare for gcc 6.0.1.






diff -aprNU7 djgpp.orig/src/makefile.cfg djgpp/src/makefile.cfg
--- djgpp.orig/src/makefile.cfg	2015-05-11 11:00:14 -0509
+++ djgpp/src/makefile.cfg	2016-04-20 21:13:24 -0509
@@ -1,7 +1,8 @@
+# Copyright (C) 2016 DJ Delorie, see COPYING.DJ for details
  # Copyright (C) 2007 DJ Delorie, see COPYING.DJ for details

  include makefile.def

  GCC_MAJOR := $(word 3, $(shell ./misc.exe | $(CROSS_GCC) -E -dD -x c - | egrep 'define\ *__GNUC__'))
  GCC_MINOR := $(word 3, $(shell ./misc.exe | $(CROSS_GCC) -E -dD -x c - | egrep 'define\ *__GNUC_MINOR__'))

@@ -22,14 +23,22 @@ endif

  ifeq ($(GCC_MAJOR),3)
  ifeq ($(GCC_MINOR),4)
  MTUNE := -mtune=i586
  endif
  endif

+ifeq ($(GCC_MAJOR),6)
+NO_BUILDINS := -fno-builtin-strlen -fno-builtin-strdup -fno-builtin-strndup \
+               -fno-builtin-stpncpy -fno-builtin-stpcpy \
+               -fno-builtin-nan -fno-builtin-nanf -fno-builtin-nanl
+else
+NO_BUILDINS :=
+endif
+
  config:	gcc.opt gpp.opt gcc-l.opt

  gcc.opt: makefile.cfg
  	@./misc.exe echo - "-MD" >gcc.opt
  	@./misc.exe echo - "-O2" >>gcc.opt
  	@./misc.exe echo - "$(MTUNE)" >>gcc.opt
  	@./misc.exe echo - "-march=i386" >>gcc.opt
@@ -44,20 +53,22 @@ gcc.opt: makefile.cfg
  	@./misc.exe echo - "-Wstrict-prototypes" >>gcc.opt
  	@./misc.exe echo - "-Wwrite-strings" >>gcc.opt
  	@./misc.exe echo - "-Wundef" >>gcc.opt
  	@./misc.exe echo - "-Wcast-align" >>gcc.opt
  	@./misc.exe echo - "-Wsign-compare" >>gcc.opt
  	@./misc.exe echo - "-nostdinc" >>gcc.opt
  	@./misc.exe echo - "$(IQUOTE)" >>gcc.opt
+	@./misc.exe echo - "$(NO_BUILDINS)" >>gcc.opt


  gcc-l.opt: makefile.cfg
  	@./misc.exe echo - "-MD" >gcc-l.opt
  	@./misc.exe echo - "-O2" >>gcc-l.opt
  	@./misc.exe echo - "$(MTUNE)" >>gcc-l.opt
  	@./misc.exe echo - "-march=i386" >>gcc-l.opt
  	@./misc.exe echo - "-Wall" >>gcc-l.opt
  	@./misc.exe echo - "-nostdinc" >>gcc-l.opt
  	@./misc.exe echo - "$(IQUOTE)" >>gcc-l.opt
+	@./misc.exe echo - "$(NO_BUILDINS)" >>gcc-l.opt

  gpp.opt: gcc.opt
  	sed -f gpp.sed $< > $@


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019