From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12180 Path: news.gmane.org!.POSTED!not-for-mail From: Didier Kryn Newsgroups: gmane.linux.lib.musl.general Subject: Building musl-cross-make with gnat in musl environement Date: Thu, 30 Nov 2017 17:30:35 +0100 Message-ID: References: <69c03d16-1946-d4e3-f909-2bd2196afe97@in2p3.fr> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------E7202512DF496B5E3421D75D" X-Trace: blaine.gmane.org 1512059468 28074 195.159.176.226 (30 Nov 2017 16:31:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 30 Nov 2017 16:31:08 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 To: musl@lists.openwall.com Original-X-From: musl-return-12196-gllmg-musl=m.gmane.org@lists.openwall.com Thu Nov 30 17:31:00 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1eKRjg-0006VR-8C for gllmg-musl@m.gmane.org; Thu, 30 Nov 2017 17:30:52 +0100 Original-Received: (qmail 27980 invoked by uid 550); 30 Nov 2017 16:30:56 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 27942 invoked from network); 30 Nov 2017 16:30:56 -0000 X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.99.2 at cczrelay02 In-Reply-To: <69c03d16-1946-d4e3-f909-2bd2196afe97@in2p3.fr> Content-Language: en-US Xref: news.gmane.org gmane.linux.lib.musl.general:12180 Archived-At: This is a multi-part message in MIME format. --------------E7202512DF496B5E3421D75D Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Le 02/11/2017 =C3=A0 10:44, Didier Kryn a =C3=A9crit=C2=A0: > =C2=A0=C2=A0=C2=A0 I report the successfull build of the cross-compiler= =20 > x86_64-musl-gcc-6.3.0 - understanding Ada - on x86_64 Debian Wheezy. > > =C2=A0=C2=A0=C2=A0 The toolchain for build was gcc-6.3.0 for Linux-Gnu = provided by=20 > Adacore.The build toolchain to build major version 6 must be at least=20 > major version 5. > > =C2=A0=C2=A0=C2=A0 Of course, the language option must be=20 > '--enable-languages=3Dada,c,c++' . > > =C2=A0=C2=A0=C2=A0 Three patches were necessary: > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 gnat63-terminals.diff: removes a #= include in a C=20 > source file. > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 gnat63-prj-attr.diff: corrects the= layout of a record in an Ada=20 > source file to prevent a warning concerning performance. > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 gnat63-xr_tabls.diff: same as the = previous.=20 =C2=A0 In a glibc environment, x86_64-musl-gcc-6.3.0 builds without erro= r=20 with the three patches I have previously reported. To check there is no=20 leak of the glibc native toolchain into the cross-compiler, I tried the=20 build in a musl chroot (without any glibc headers or library), still=20 with '--enable-languages=3Dada,c,c++'. =C2=A0=C2=A0=C2=A0 In a first attempt, the compilation fails with the fo= llowing error: ---------------------------------------- In file included from ../../src_toolchain/gcc/ada/adaint.h:290:0, =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 from ../../src_toolchain/gcc/ada/adadecode.c:45:= /usr/pkg/gcc-6.3/lib/gcc/x86_64-pc-linux-musl/6.3.0/../../../../x86_64-pc= -linux-musl/include/sched.h:76:7:=20 error: attempt to use poisoned "calloc" =C2=A0void *calloc(size_t, size_t); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ^ /usr/pkg/gcc-6.3/lib/gcc/x86_64-pc-linux-musl/6.3.0/../../../../x86_64-pc= -linux-musl/include/sched.h:116:36:=20 error: attempt to use poisoned "calloc" =C2=A0#define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n))) ---------------------------------------- =C2=A0=C2=A0=C2=A0 The Ada language has "tasking" primitives, which are = nowadays based=20 on POSIX threads. For this, adaint.h and other files include =20 which, unfortunately, contains a declaration of calloc() and references=20 to it. This is unfortunate because calloc() is poisoned=C2=A0 by gcc, to = avoid interferences with its own allocation functions, and Gnat does=20 only need a small part of sched.h. =C2=A0=C2=A0=C2=A0 There must be a necessity, specific to musl, to make = use of=20 calloc() in sched.h, because glibc doesn't do so. =C2=A0=C2=A0=C2=A0 A workaround, provided by the patch gnat63-adaint.dif= f, is to=20 replace #include with the few lines of this file actually=20 needed in adaint.h. The patch contains also #define _SCHED_H, which is=20 necessary to prevent the inclusion of sched.h by other files, directly=20 or indirectly. =C2=A0=C2=A0=C2=A0 With this additional patch,=C2=A0 x86_64-musl-gcc-6.3= =2E0 builds without=20 error both in a glibc environement and in a musl environment. =C2=A0=C2=A0=C2=A0 Didier --------------E7202512DF496B5E3421D75D Content-Type: text/x-patch; name="gnat63-adaint.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gnat63-adaint.diff" --- gcc-6.3.0-A/gcc/ada/adaint.c +++ gcc-6.3.0-B/gcc/ada/adaint.c @@ -3086,7 +3086,7 @@ #endif #if defined (__linux__) -#include +/* do not #include */ /* glibc versions earlier than 2.7 do not define the routines to handle dynamically allocated CPU sets. For these targets, we use the static --- gcc-6.3.0-A/gcc/ada/adaint.h +++ gcc-6.3.0-B/gcc/ada/adaint.h @@ -287,7 +287,17 @@ /* Routines for interface to required CPU set primitives */ -#include +/* Do not #include , but copy part of it and prevent its inclusion */ +# ifndef _SCHED_H +# define _SCHED_H +typedef struct cpu_set_t { unsigned long __bits[128/sizeof(long)]; } cpu_set_t; +# define CPU_ZERO_S(size,set) memset(set,0,size) +# define CPU_ZERO(set) CPU_ZERO_S(sizeof(cpu_set_t),set) +# define __CPU_op_S(i, size, set, op) ( (i)/8U >= (size) ? 0 : \ + (((unsigned long *)(set))[(i)/8/sizeof(long)] op (1UL<<((i)%(8*sizeof(long))))) ) +# define CPU_SET_S(i, size, set) __CPU_op_S(i, size, set, |=) +# define CPU_SET(i, set) CPU_SET_S(i,sizeof(cpu_set_t),set) +# endif extern cpu_set_t *__gnat_cpu_alloc (size_t); extern size_t __gnat_cpu_alloc_size (size_t); --------------E7202512DF496B5E3421D75D--