From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 8198F3888C45 for ; Tue, 29 Mar 2022 09:14:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8198F3888C45 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.90,219,1643702400"; d="scan'208";a="76330148" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 29 Mar 2022 01:14:15 -0800 IronPort-SDR: k0OuZ7QOa+y/0RD6P5Wp/DYgfHXyoHMlKBVbi4zyVOkMLzPngnxdVunzR0YySMoc+RCiZ2e5iC YAi/896rnXxrooz4PaD0PvytazQJCU+BVz6k1zBDNxuI2ytChnNWPse50kCsWvjpNvmAWBDFee lfBngpx8QEAjAKSD0ziMge2os0zfnvdZIgObpHTeqmwJTsMVRQ/IZJ6fVuAIPw4vFF6iAvueOT eK9o3ZyYRYnnG4DiMblBfBMANB+Iz5IbQiQvBpySkCi698VFZ4KgoMuyg61Llh7F2lWYiHoVcm L1Q= Message-ID: <0e04b11a-1b6d-c70a-c0fe-4ece59996461@codesourcery.com> Date: Tue, 29 Mar 2022 11:14:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Content-Language: en-US To: From: Tobias Burnus Subject: Build-dependency issues with ELIX_LEVEL Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-08.mgc.mentorg.com (139.181.222.8) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, KAM_ASCII_DIVIDERS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2022 09:14:18 -0000 Hello, there is an issue with ELIX_LEVEL and dependencies. Namely, files compiled for a given ELIX_LEVEL (here: 1) still call functions which are only available in a higher ELIX_LEVEL. Expected: Either those files are also build - or the function is not called (#ifdef or also removing the other file from the ELIX_LEVEL). The issue seems to be old - but popped up for nvptx (link error when using 'fprintf), but I think it should be addressed in general. * * * The original issue (missing '_fputwc_r' symbol) did show up with nvptx, whi= ch uses #define _ELIX_LEVEL 1 #define _WIDE_ORIENT 1 #undef _NANO_FORMATTED_IO The problem is: newlib/libc/stdio/vfprintf.c (and newlib/libc/stdio/nano-vfprintf.c ) that are compiled via newlib/Makefile.in as @HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_TRUE@ libc/stdio/nano-= vfprintf_float.c \ @HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/vfpri= ntf.c \ both files have #ifdef _WIDE_ORIENT ... if (_fputwc_r (ptr, p[i], fp) =3D=3D WEOF) But _fputwc_r is only available via: @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@HAVE_STDIO_DIR= _TRUE@ libc/stdio/fputwc.c \ I have not studied the ELIX_LEVEL documentation in depth, but I think the f= ollowing is the proper solution (tested with nvptx, i.e. only the non-nano version): -------------------------------------- newlib: Only call _fputwc_r if ELIX_LEVEL >=3D 3 --- a/newlib/libc/stdio/nano-vfprintf.c +++ b/newlib/libc/stdio/nano-vfprintf.c @@ -359 +359 @@ __sprint_r (struct _reent *ptr, -#ifdef _WIDE_ORIENT +#if defined _WIDE_ORIENT && (!defined _ELIX_LEVEL || _ELIX_LEVEL >=3D 3) @@ -410 +410 @@ __sfputs_r (struct _reent *ptr, -#ifdef _WIDE_ORIENT +#if defined _WIDE_ORIENT && (!defined _ELIX_LEVEL || _ELIX_LEVEL >=3D 3) --- a/newlib/libc/stdio/vfprintf.c +++ b/newlib/libc/stdio/vfprintf.c @@ -373 +373 @@ __sfputs_r (struct _reent *ptr, -#ifdef _WIDE_ORIENT +#if defined _WIDE_ORIENT && (!defined _ELIX_LEVEL || _ELIX_LEVEL >=3D 3) @@ -409 +409 @@ __sprint_r (struct _reent *ptr, -#ifdef _WIDE_ORIENT +#if defined _WIDE_ORIENT && (!defined _ELIX_LEVEL || _ELIX_LEVEL >=3D 3) -------------------------------------- * * * Looking closer at the generated files, there are also more issues (see bottom for a list). Analyzing another one: ./newlib/libc/stdio/vdiprintf.c calls newlib/libc/stdio/vfiprintf.c's _vfiprintf_r which calls libc/stdio/vasniprintf.c's (or, '#ifdef _NANO_FORMATTED_IO',= libc/stdio/vasnprintf.c's) _vasniprintf_r which then calls libc/stdio/nano-vfprintf.c's _svfiprintf_r However, while @HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/vdipr= intf.c \ and likewise _svfiprintf_r, the vasniprintf.c is missing for NANO and for non-NANO it is only enabled for ELIX_LEVEL 4. Untested fix: ------------------------------------------ --- a/newlib/libc/stdio/Makefile.inc +++ b/newlib/libc/stdio/Makefile.inc @@ -9,2 +9,3 @@ libc_a_SOURCES +=3D \ %D%/nano-vfprintf_i.c \ + %D%/nano-vasniprintf.c \ %D%/nano-vfscanf.c \ @@ -26,2 +27,3 @@ libc_a_SOURCES +=3D \ %D%/vdiprintf.c \ + %D%/vasnprintf.c \ %D%/vfprintf.c \ @@ -184,3 +186,2 @@ else %D%/ungetwc.c \ - %D%/vasnprintf.c \ %D%/vswprintf.c \ ------------------------------------------ Thoughts? Tobias PS: The full list of symbols called - but not provided in libc (compiled for nvptx) is the following. Note: I might have misgreped and I have only had a closer look at _fputwc_r and _vasniprintf_r. =3D=3D=3D __ffsdi2 =3D=3D string/libc_a-ffsl.o string/libc_a-ffsll.o =3D=3D=3D __hash_open =3D=3D search/libc_a-ndbm.o =3D=3D=3D _fgetwc_r =3D=3D stdio/libc_a-vfiwscanf.o stdio/libc_a-vfwscanf.o =3D=3D=3D _fputwc_r =3D=3D stdio/libc_a-vfiprintf.o =3D=3D=3D _fseeko_r =3D=3D stdio/libc_a-fseek.o =3D=3D=3D _ftello_r =3D=3D stdio/libc_a-ftell.o =3D=3D=3D _memalign_r =3D=3D stdlib/libc_a-aligned_alloc.o =3D=3D=3D _ungetwc_r =3D=3D stdio/libc_a-vfiwscanf.o stdio/libc_a-vfwscanf.o =3D=3D=3D _vasniprintf_r =3D=3D stdio/libc_a-vdiprintf.o =3D=3D=3D _vasnprintf_r =3D=3D stdio/libc_a-vdprintf.o =3D=3D=3D _wcrtomb_r =3D=3D stdio/libc_a-svfiwscanf.o stdio/libc_a-svfwscanf.o stdio/libc_a-vfiwscanf.o stdio/libc_a-vfwscanf.o =3D=3D=3D _wcsnrtombs_l =3D=3D stdlib/libc_a-wcstod.o =3D=3D=3D btowc =3D=3D locale/libc_a-locale.o stdio/libc_a-vfiwprintf.o stdio/libc_a-svfwprintf.o stdio/libc_a-vfwprintf.o stdio/libc_a-svfiwprintf.o =3D=3D=3D fcntl =3D=3D reent/libc_a-fcntlr.o =3D=3D=3D getentropy =3D=3D stdlib/libc_a-arc4random.o =3D=3D=3D getpid; =3D=3D reent/libc_a-signalr.o =3D=3D=3D gettimeofday =3D=3D reent/libc_a-gettimeofdayr.o time/libc_a-time.o =3D=3D=3D iswcntrl =3D=3D string/libc_a-wcwidth.o =3D=3D=3D iswprint =3D=3D string/libc_a-wcwidth.o =3D=3D=3D iswspace =3D=3D stdio/libc_a-svfiwscanf.o stdio/libc_a-svfwscanf.o stdio/libc_a-vfiwscanf.o stdio/libc_a-vfwscanf.o stdlib/libc_a-wcstod.o stdlib/libc_a-wcstoul.o stdlib/libc_a-wcstoll.o stdlib/libc_a-wcstoimax.o stdlib/libc_a-wcstol.o stdlib/libc_a-wcstoumax.o stdlib/libc_a-wcstoull.o =3D=3D=3D iswspace_l =3D=3D stdlib/libc_a-wcstod.o stdlib/libc_a-wcstoul.o stdlib/libc_a-wcstoll.o stdlib/libc_a-wcstoimax.o stdlib/libc_a-wcstol.o stdlib/libc_a-wcstoumax.o stdlib/libc_a-wcstoull.o =3D=3D=3D kill =3D=3D reent/libc_a-signalr.o signal/libc_a-signal.o =3D=3D=3D link =3D=3D reent/libc_a-linkr.o reent/libc_a-unlinkr.o reent/libc_a-renamer.o reent/libc_a-renamer.o stdio/libc_a-remove.o =3D=3D=3D malloc =3D=3D machine/nvptx/libc_a-mallocr.o machine/nvptx/libc_a-realloc.o machine/nvptx/libc_a-calloc.o machine/nvptx/libc_a-malloc.o signal/libc_a-signal.o stdio/libc_a-svfiprintf.o stdio/libc_a-setvbuf.o stdio/libc_a-tmpnam.o stdio/libc_a-vfiwprintf.o stdio/libc_a-svfwprintf.o stdio/libc_a-makebuf.o stdio/libc_a-svfprintf.o stdio/libc_a-findfp.o stdio/libc_a-vfwprintf.o stdio/libc_a-ungetc.o stdio/libc_a-svfiwprintf.o stdio/libc_a-fvwrite.o stdlib/libc_a-quick_exit.o stdlib/libc_a-__atexit.o stdlib/libc_a-wcstod.o string/libc_a-strdup_r.o time/libc_a-tzset_r.o =3D=3D=3D memmem =3D=3D string/libc_a-strnstr.o =3D=3D=3D mkdir =3D=3D reent/libc_a-mkdirr.o =3D=3D=3D sbrk =3D=3D reent/libc_a-sbrkr.o =3D=3D=3D stat =3D=3D reent/libc_a-statr.o reent/libc_a-fstatr.o stdio/libc_a-makebuf.o =3D=3D=3D strncasecmp_l =3D=3D time/libc_a-strptime.o =3D=3D=3D swprintf =3D=3D stdio/libc_a-svfwscanf.o stdio/libc_a-vfwscanf.o time/libc_a-wcsftime.o =3D=3D=3D times =3D=3D reent/libc_a-timesr.o =3D=3D=3D towlower =3D=3D time/libc_a-wcsftime.o =3D=3D=3D wcrtomb =3D=3D stdio/libc_a-svfiwscanf.o stdio/libc_a-svfiwscanf.o stdio/libc_a-svfwscanf.o stdio/libc_a-svfwscanf.o stdio/libc_a-vfiwscanf.o stdio/libc_a-vfiwscanf.o stdio/libc_a-vfwscanf.o stdio/libc_a-vfwscanf.o ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstra=C3=9Fe 201= , 80634 M=C3=BCnchen; Gesellschaft mit beschr=C3=A4nkter Haftung; Gesch=C3= =A4ftsf=C3=BChrer: Thomas Heurung, Frank Th=C3=BCrauf; Sitz der Gesellschaf= t: M=C3=BCnchen; Registergericht M=C3=BCnchen, HRB 106955