From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 63340 invoked by alias); 12 Jun 2017 09:17:02 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 63284 invoked by uid 89); 12 Jun 2017 09:17:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=installations, observed, vx7, hacks X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Jun 2017 09:16:58 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id E409A8134F; Mon, 12 Jun 2017 11:17:00 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id m92roQeZuMCE; Mon, 12 Jun 2017 11:17:00 +0200 (CEST) Received: from idefix.act-europe.fr (idefix.act-europe.fr [IPv6:2a02:2ab8:224:1:ca2a:14ff:fe50:b3c9]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id A1D54812D6; Mon, 12 Jun 2017 11:17:00 +0200 (CEST) From: Olivier Hainque Content-Type: multipart/mixed; boundary="Apple-Mail=_B2FE658D-1379-409B-9C0F-983298ADBDCD" Subject: improve stdint.h handling for VxWorks Date: Mon, 12 Jun 2017 09:17:00 -0000 Message-Id: <93FEF9F0-A6DB-4E16-80EE-9A9C83CA919C@adacore.com> Cc: Douglas B Rupp , Joel Brobecker , Joseph Myers To: GCC Patches , Nathan Sidwell Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) X-SW-Source: 2017-06/txt/msg00761.txt.bz2 --Apple-Mail=_B2FE658D-1379-409B-9C0F-983298ADBDCD Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Content-length: 3139 Building a powerpc-wrs-vxworks compiler with a very recent mainline fails with numerous instances or error like: In file included from /powerpc-wrs-vxworks/sys-include/types/vxType= sOld.h:123:0, from /gcc/include-fixed/stdint.h:16, from /powerpc-wrs-vxworks/sys-include/types/vxANSI= .h:59, from /gcc/include-fixed/stdio.h:84, from /libgcc/../gcc/tsystem.h:87, from /libgcc/unwind-dw2.c:26: /powerpc-wrs-vxworks/sys-include/base/e_vxTypesOld.h:260:5: error: = unknown type name 'int8_t' Note that stdint.h is picked from /gcc/include-fixed. There are several issues with fixincludes for VxWorks and I'll come to those later. The one we hit here suggests more generally that the current handling of stdint.h needs to be improved. Indeed, the current "hack" (in fixincludes parlance) for stdint on VxWorks = has become incorrect, as it produces a stdint.h file which starts with: /* get int*_t, uint*_t */ #include This doesn't work in general as on the VxWorks end (looking at 6.9), we apparently have the opposite expectation in types/vxTypes.h, via #ifdef _WRS_KERNEL #include /* includes kernel's stdint.h */ The proposal here is to remove the fixincludes hack and have gcc provide stdint.h instead. The attached patch does this by setting use_gcc_stdint to "provide" in config.gcc and adding vxworks-stdint.h, crafted by looking at the definitions of the relevant types in headers from a number of VxWorks installations (version and target variants). Thanks to Doug Rupp for the in investigation and work involved. An alternative resolution to the immediate build issue would be to just rem= ove the fixincludes hack. We are observing numerous testsuite failures afterwar= ds in this setup, however, as we then rely on the system stdint.h in this case and it misses at least some macro definitions in some configurations. This, in principle, should be solvable with alternative fixincludes hacks, as suggested by https://gcc.gnu.org/ml/gcc/2004-11/msg00254.html. Getting this right for the wide range of VxWorks variants is tedious and error prone though, and it seems much simpler to just override consistently with a gcc provided version. The proposed patch both fixes the build issues and addresses the shortcomin= gs of VxWorks' stdint.h that we have observed, curing hundreds of test failures in our nightly testsuite runs, on both vx6 and vx7. It also provides a vxworks-stdint.h file, which recent comments on bug 448 suggest was missing. See e.g. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D448#c31 (Joseph cc'ed). Nathan, how does this look to you ? Thanks in advance, With Kind Regards, Olivier 2017-06-12 Doug Rupp gcc/ * config.gcc (*-*-vxworks*): Set use_gcc_stdint to "provide". Append vxworks-stdint.h to the tm_file list. * config/vxworks-stdint.h: New file. fixincludes/ * inclhack.def (AAB_vxworks_stdint): Remove hack. * fixincl.x: Regenerate. --Apple-Mail=_B2FE658D-1379-409B-9C0F-983298ADBDCD Content-Disposition: attachment; filename=vx-stdint.diff Content-Type: application/octet-stream; name="vx-stdint.diff" Content-Transfer-Encoding: 7bit Content-length: 12585 Index: gcc/config.gcc =================================================================== --- gcc/config.gcc (revision 248832) +++ gcc/config.gcc (working copy) @@ -917,6 +917,8 @@ xm_defines=POSIX extra_options="${extra_options} vxworks.opt" extra_objs="$extra_objs vxworks.o" + use_gcc_stdint=provide + tm_file="${tm_file} vxworks-stdint.h" case ${enable_threads} in no) ;; "" | yes | vxworks) thread_file='vxworks' ;; Index: gcc/config/vxworks-stdint.h =================================================================== --- gcc/config/vxworks-stdint.h (revision 0) +++ gcc/config/vxworks-stdint.h (revision 0) @@ -0,0 +1,53 @@ +/* Definitions for types on systems using VxWorks. + Copyright (C) 2017 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +#define SIG_ATOMIC_TYPE "unsigned char" + +#define INT8_TYPE "signed char" +#define INT16_TYPE "short int" +#define INT32_TYPE "int" +#define INT64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int") +#define UINT8_TYPE "unsigned char" +#define UINT16_TYPE "short unsigned int" +#define UINT32_TYPE "unsigned int" +#define UINT64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int") +#define INT_LEAST8_TYPE "signed char" +#define INT_LEAST16_TYPE "short int" +#define INT_LEAST32_TYPE "int" +#define INT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int") +#define UINT_LEAST8_TYPE "unsigned char" +#define UINT_LEAST16_TYPE "short unsigned int" +#define UINT_LEAST32_TYPE "unsigned int" +#define UINT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int") +#define INT_FAST8_TYPE "signed char" +#define INT_FAST16_TYPE "int" +#define INT_FAST32_TYPE "int" +#define INT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int") +#define UINT_FAST8_TYPE "unsigned char" +#define UINT_FAST16_TYPE "unsigned int" +#define UINT_FAST32_TYPE "unsigned int" +#define UINT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int") + +#define INTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int") +#define UINTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int") Index: fixincludes/fixincl.x =================================================================== --- fixincludes/fixincl.x (revision 248673) +++ fixincludes/fixincl.x (working copy) @@ -1,12 +1,12 @@ /* -*- buffer-read-only: t -*- vi: set ro: - * + * * DO NOT EDIT THIS FILE (fixincl.x) - * - * It has been AutoGen-ed Saturday February 25, 2017 at 03:25:44 PM EST + * + * It has been AutoGen-ed June 8, 2017 at 10:50:04 AM by AutoGen 5.18.4 * From the definitions inclhack.def * and the template file fixincl */ -/* DO NOT SVN-MERGE THIS FILE, EITHER Sat 25 Feb 2017 15:25:44 EST +/* DO NOT SVN-MERGE THIS FILE, EITHER Thu Jun 8 10:50:04 CEST 2017 * * You must regenerate it. Use the ./genfixes script. * @@ -15,7 +15,7 @@ * certain ANSI-incompatible system header files which are fixed to work * correctly with ANSI C and placed in a directory that GNU C will search. * - * This file contains 248 fixup descriptions. + * This file contains 247 fixup descriptions. * * See README for more information. * @@ -581,120 +581,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * - * Description of Aab_Vxworks_Stdint fix - */ -tSCC zAab_Vxworks_StdintName[] = - "AAB_vxworks_stdint"; - -/* - * File name selection pattern - */ -tSCC zAab_Vxworks_StdintList[] = - "stdint.h\0"; -/* - * Machine/OS name selection pattern - */ -tSCC* apzAab_Vxworks_StdintMachs[] = { - "*-*-vxworks*", - (const char*)NULL }; -#define AAB_VXWORKS_STDINT_TEST_CT 0 -#define aAab_Vxworks_StdintTests (tTestDesc*)NULL - -/* - * Fix Command Arguments for Aab_Vxworks_Stdint - */ -static const char* apzAab_Vxworks_StdintPatch[] = { -"#ifndef _STDINT_H\n\ -#define _STDINT_H\n\ -/* get int*_t, uint*_t */\n\ -#include \n\n\ -/* get legacy vxworks types for compatibility */\n\ -#include \n\n\ -typedef long intptr_t;\n\ -typedef unsigned long uintptr_t;\n\n\ -typedef int64_t intmax_t;\n\ -typedef uint64_t uintmax_t;\n\n\ -typedef int8_t int_least8_t;\n\ -typedef int16_t int_least16_t;\n\ -typedef int32_t int_least32_t;\n\ -typedef int64_t int_least64_t;\n\n\ -typedef uint8_t uint_least8_t;\n\ -typedef uint16_t uint_least16_t;\n\ -typedef uint32_t uint_least32_t;\n\ -typedef uint64_t uint_least64_t;\n\n\ -typedef int8_t int_fast8_t;\n\ -typedef int int_fast16_t;\n\ -typedef int32_t int_fast32_t;\n\ -typedef int64_t int_fast64_t;\n\n\ -typedef uint8_t uint_fast8_t;\n\ -typedef unsigned int uint_fast16_t;\n\ -typedef uint32_t uint_fast32_t;\n\ -typedef uint64_t uint_fast64_t;\n\n\ -/* Ranges */\n\ -#define UINT8_MAX (~(uint8_t)0)\n\ -#define UINT8_MIN 0\n\ -#define UINT16_MAX (~(uint16_t)0)\n\ -#define UINT16_MIN 0\n\ -#define UINT32_MAX (~(uint32_t)0)\n\ -#define UINT32_MIN 0\n\ -#define UINT64_MAX (~(uint64_t)0)\n\ -#define UINT64_MIN 0\n\n\ -#define UINTPTR_MAX (~(uintptr_t)0)\n\ -#define UINTPTR_MIN 0\n\n\ -/* Need to do int_fast16_t as well, as type\n\ - size may be architecture dependent */\n\ -#define UINT_FAST16_MAX (~(uint_fast16_t)0)\n\ -#define UINT_FAST16_MAX 0\n\n\ -#define INT8_MAX (UINT8_MAX>>1)\n\ -#define INT8_MIN (INT8_MAX+1)\n\ -#define INT16_MAX (UINT16_MAX>>1)\n\ -#define INT16_MIN (INT16_MAX+1)\n\ -#define INT32_MAX (UINT32_MAX>>1)\n\ -#define INT32_MIN (INT32_MAX+1)\n\ -#define INT64_MAX (UINT64_MAX>>1)\n\ -#define INT64_MIN (INT64_MAX+1)\n\n\ -#define INTPTR_MAX (UINTPTR_MAX>>1)\n\ -#define INTPTR_MIN (INTPTR_MAX+1)\t\n\n\ -#define INT_FAST16_MAX (UINT_FAST16_MAX>>1)\n\ -#define INT_FAST16_MIN (INT_FAST16_MAX+1)\n\n\ -/* now define equiv. constants */\n\ -#define UINT_FAST8_MAX UINT8_MAX\n\ -#define UINT_FAST8_MIN UINT_FAST8_MIN\n\ -#define INT_FAST8_MAX INT8_MAX\n\ -#define INT_FAST8_MIN INT8_MIN\n\ -#define UINT_FAST32_MAX UINT32_MAX\n\ -#define UINT_FAST32_MIN UINT32_MIN\n\ -#define INT_FAST32_MAX INT32_MAX\n\ -#define INT_FAST32_MIN INT32_MIN\n\ -#define UINT_FAST64_MAX UINT64_MAX\n\ -#define UINT_FAST64_MIN UINT64_MIN\n\ -#define INT_FAST64_MAX INT64_MAX\n\ -#define INT_FAST64_MIN INT64_MIN\n\n\ -#define UINT_LEAST8_MAX UINT8_MAX\n\ -#define UINT_LEAST8_MIN UINT8_MIN\n\ -#define INT_LEAST8_MAX INT8_MAX\n\ -#define INT_LEAST8_MIN INT8_MIN\n\ -#define UINT_LEAST16_MAX UINT16_MAX\n\ -#define UINT_LEAST16_MIN UINT16_MIN\n\ -#define INT_LEAST16_MAX INT16_MAX\n\ -#define INT_LEAST16_MIN INT16_MIN\n\ -#define UINT_LEAST32_MAX UINT32_MAX\n\ -#define UINT_LEAST32_MIN UINT32_MIN\n\ -#define INT_LEAST32_MAX INT32_MAX\n\ -#define INT_LEAST32_MIN INT32_MIN\n\ -#define UINT_LEAST64_MAX UINT64_MAX\n\ -#define UINT_LEAST64_MIN UINT64_MIN\n\ -#define INT_LEAST64_MAX INT64_MAX\n\ -#define INT_LEAST64_MIN INT64_MIN\n\n\ -#define UINTMAX_MAX UINT64_MAX\n\ -#define UINTMAX_MIN UINT64_MIN\n\ -#define INTMAX_MAX INT64_MAX\n\ -#define INTMAX_MIN INT64_MIN\n\n\ -#endif", - (char*)NULL }; - -/* * * * * * * * * * * * * * * * * * * * * * * * * * - * * Description of Aab_Vxworks_Unistd fix */ tSCC zAab_Vxworks_UnistdName[] = @@ -10141,7 +10027,7 @@ */ #define REGEX_COUNT 285 #define MACH_LIST_SIZE_LIMIT 187 -#define FIX_COUNT 248 +#define FIX_COUNT 247 /* * Enumerate the fixes @@ -10157,7 +10043,6 @@ AAB_SUN_MEMCPY_FIXIDX, AAB_VXWORKS_ASSERT_FIXIDX, AAB_VXWORKS_REGS_VXTYPES_FIXIDX, - AAB_VXWORKS_STDINT_FIXIDX, AAB_VXWORKS_UNISTD_FIXIDX, AIX_ASSERT_FIXIDX, AIX_COMPLEX_FIXIDX, @@ -10448,11 +10333,6 @@ AAB_VXWORKS_REGS_VXTYPES_TEST_CT, FD_MACH_ONLY | FD_REPLACEMENT, aAab_Vxworks_Regs_VxtypesTests, apzAab_Vxworks_Regs_VxtypesPatch, 0 }, - { zAab_Vxworks_StdintName, zAab_Vxworks_StdintList, - apzAab_Vxworks_StdintMachs, - AAB_VXWORKS_STDINT_TEST_CT, FD_MACH_ONLY | FD_REPLACEMENT, - aAab_Vxworks_StdintTests, apzAab_Vxworks_StdintPatch, 0 }, - { zAab_Vxworks_UnistdName, zAab_Vxworks_UnistdList, apzAab_Vxworks_UnistdMachs, AAB_VXWORKS_UNISTD_TEST_CT, FD_MACH_ONLY | FD_REPLACEMENT, Index: fixincludes/inclhack.def =================================================================== --- fixincludes/inclhack.def (revision 248673) +++ fixincludes/inclhack.def (working copy) @@ -427,122 +427,6 @@ }; /* - * Make VxWorks stdint.h a bit more compliant - add typedefs - */ -fix = { - hackname = AAB_vxworks_stdint; - files = stdint.h; - mach = "*-*-vxworks*"; - - replace = <<- _EndOfHeader_ - #ifndef _STDINT_H - #define _STDINT_H - /* get int*_t, uint*_t */ - #include - - /* get legacy vxworks types for compatibility */ - #include - - typedef long intptr_t; - typedef unsigned long uintptr_t; - - typedef int64_t intmax_t; - typedef uint64_t uintmax_t; - - typedef int8_t int_least8_t; - typedef int16_t int_least16_t; - typedef int32_t int_least32_t; - typedef int64_t int_least64_t; - - typedef uint8_t uint_least8_t; - typedef uint16_t uint_least16_t; - typedef uint32_t uint_least32_t; - typedef uint64_t uint_least64_t; - - typedef int8_t int_fast8_t; - typedef int int_fast16_t; - typedef int32_t int_fast32_t; - typedef int64_t int_fast64_t; - - typedef uint8_t uint_fast8_t; - typedef unsigned int uint_fast16_t; - typedef uint32_t uint_fast32_t; - typedef uint64_t uint_fast64_t; - - /* Ranges */ - #define UINT8_MAX (~(uint8_t)0) - #define UINT8_MIN 0 - #define UINT16_MAX (~(uint16_t)0) - #define UINT16_MIN 0 - #define UINT32_MAX (~(uint32_t)0) - #define UINT32_MIN 0 - #define UINT64_MAX (~(uint64_t)0) - #define UINT64_MIN 0 - - #define UINTPTR_MAX (~(uintptr_t)0) - #define UINTPTR_MIN 0 - - /* Need to do int_fast16_t as well, as type - size may be architecture dependent */ - #define UINT_FAST16_MAX (~(uint_fast16_t)0) - #define UINT_FAST16_MAX 0 - - #define INT8_MAX (UINT8_MAX>>1) - #define INT8_MIN (INT8_MAX+1) - #define INT16_MAX (UINT16_MAX>>1) - #define INT16_MIN (INT16_MAX+1) - #define INT32_MAX (UINT32_MAX>>1) - #define INT32_MIN (INT32_MAX+1) - #define INT64_MAX (UINT64_MAX>>1) - #define INT64_MIN (INT64_MAX+1) - - #define INTPTR_MAX (UINTPTR_MAX>>1) - #define INTPTR_MIN (INTPTR_MAX+1) - - #define INT_FAST16_MAX (UINT_FAST16_MAX>>1) - #define INT_FAST16_MIN (INT_FAST16_MAX+1) - - /* now define equiv. constants */ - #define UINT_FAST8_MAX UINT8_MAX - #define UINT_FAST8_MIN UINT_FAST8_MIN - #define INT_FAST8_MAX INT8_MAX - #define INT_FAST8_MIN INT8_MIN - #define UINT_FAST32_MAX UINT32_MAX - #define UINT_FAST32_MIN UINT32_MIN - #define INT_FAST32_MAX INT32_MAX - #define INT_FAST32_MIN INT32_MIN - #define UINT_FAST64_MAX UINT64_MAX - #define UINT_FAST64_MIN UINT64_MIN - #define INT_FAST64_MAX INT64_MAX - #define INT_FAST64_MIN INT64_MIN - - #define UINT_LEAST8_MAX UINT8_MAX - #define UINT_LEAST8_MIN UINT8_MIN - #define INT_LEAST8_MAX INT8_MAX - #define INT_LEAST8_MIN INT8_MIN - #define UINT_LEAST16_MAX UINT16_MAX - #define UINT_LEAST16_MIN UINT16_MIN - #define INT_LEAST16_MAX INT16_MAX - #define INT_LEAST16_MIN INT16_MIN - #define UINT_LEAST32_MAX UINT32_MAX - #define UINT_LEAST32_MIN UINT32_MIN - #define INT_LEAST32_MAX INT32_MAX - #define INT_LEAST32_MIN INT32_MIN - #define UINT_LEAST64_MAX UINT64_MAX - #define UINT_LEAST64_MIN UINT64_MIN - #define INT_LEAST64_MAX INT64_MAX - #define INT_LEAST64_MIN INT64_MIN - - #define UINTMAX_MAX UINT64_MAX - #define UINTMAX_MIN UINT64_MIN - #define INTMAX_MAX INT64_MAX - #define INTMAX_MIN INT64_MIN - - #endif - _EndOfHeader_; -}; - -/* * This hack makes makes unistd.h more POSIX-compliant on VxWorks */ fix = { --Apple-Mail=_B2FE658D-1379-409B-9C0F-983298ADBDCD--