Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dFN4N-0004GZ-Rs for pgsql-hackers@arkaria.postgresql.org; Mon, 29 May 2017 15:58:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dFN4N-00022C-CX for pgsql-hackers@arkaria.postgresql.org; Mon, 29 May 2017 15:58:59 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dFN4L-0001xs-3e; Mon, 29 May 2017 15:58:57 +0000 Received: from feynman.df7cb.de ([195.49.152.168]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dFN4H-0002NL-L8; Mon, 29 May 2017 15:58:55 +0000 Received: from msg.df7cb.de (unknown [IPv6:2a02:908:1470:60c0:76e5:bff:fef3:7e00]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by feynman.df7cb.de (Postfix) with ESMTPSA id 3wc1cp4Wbcz3Dyv; Mon, 29 May 2017 17:58:50 +0200 (CEST) Date: Mon, 29 May 2017 17:58:50 +0200 From: Christoph Berg To: Andres Freund , Jason Petersen , pgsql-pkg-debian@postgresql.org, PostgreSQL Hackers Subject: Re: [PATCH] relocation truncated to fit: citus build failure on s390x Message-ID: <20170529155850.qojdfrwkkqnjb3ap@msg.df7cb.de> Mail-Followup-To: Christoph Berg , Andres Freund , Jason Petersen , pgsql-pkg-debian@postgresql.org, PostgreSQL Hackers References: <980D4281-A01F-4F5D-9874-FFED701F403F@citusdata.com> <20160426151339.GF12563@msg.df7cb.de> <20160426153235.GA2862@msg.df7cb.de> <20160427230516.44fuzdxlifch2wwp@alap3.anarazel.de> <20160428080824.GA22412@msg.df7cb.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160428080824.GA22412@msg.df7cb.de> User-Agent: NeoMutt/20170113 (1.7.2) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Re: To Andres Freund 2016-04-28 <20160428080824.GA22412@msg.df7cb.de> > > I'm not clear why citus triggers this, when other extensions don't? > > Maybe it's simply because citus.so is bigger than all the other > extension .so files: > > -fpic > Generate position-independent code (PIC) suitable for use > in a shared library, if supported for the target machine. > Such code accesses all constant addresses through a global > offset table (GOT). The dynamic loader resolves the GOT > entries when the program starts (the dynamic loader is not > part of GCC; it is part of the operating system). If the > GOT size for the linked executable exceeds a machine- > specific maximum size, you get an error message from the > linker indicating that -fpic does not work; in that case, > recompile with -fPIC instead. (These maximums are 8k on > the SPARC and 32k on the m68k and RS/6000. The 386 has no > such limit.) > > Position-independent code requires special support, and > therefore works only on certain machines. For the 386, GCC > supports PIC for System V but not for the Sun 386i. Code > generated for the IBM RS/6000 is always > position-independent. > > When this flag is set, the macros "__pic__" and "__PIC__" > are defined to 1. > > -fPIC > If supported for the target machine, emit > position-independent code, suitable for dynamic linking and > avoiding any limit on the size of the global offset table. > This option makes a difference on the m68k, PowerPC and > SPARC. > > Position-independent code requires special support, and > therefore works only on certain machines. > > When this flag is set, the macros "__pic__" and "__PIC__" > are defined to 2. > > This doesn't mention s390(x), but citus.so 382952 bytes (on amd64) is > well beyond the 8k/32k limits mentioned above. > > PostgreSQL itself links correctly on s390x: > ... -I/usr/include/mit-krb5 -fPIC -pie -I../../../../src/include > > I'm not an expert in compiler flags, but it seems to me CFLAGS_SL is > wrong on s390(x) in Makefile.port, it should use -fPIC like sparc. After talking to a s390x Debian porter, -fPIC is the correct flag to use. The quoted patch made the previously failing builds for citus and pglogical (which have larger-than-average .so files) on s390x succeed (and the sparc64 case still works): --- a/src/makefiles/Makefile.linux +++ b/src/makefiles/Makefile.linux @@ -5,7 +5,8 @@ export_dynamic = -Wl,-E rpath = -Wl,-rpath,'$(rpathdir)',--enable-new-dtags DLSUFFIX = .so -ifeq "$(findstring sparc,$(host_cpu))" "sparc" +# Enable -fPIC to avoid "relocation truncated to fit" linker errors +ifneq "$(filter sparc% s390%,$(host_cpu))" "" CFLAGS_SL = -fPIC else CFLAGS_SL = -fpic The patch was made against 9.6; I'd opt to include it in master and the back branches. https://buildd.debian.org/status/logs.php?pkg=citus&arch=s390x https://buildd.debian.org/status/logs.php?pkg=pglogical&arch=s390x Christoph -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers