From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 100781 invoked by alias); 16 Apr 2018 19:51:24 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 100742 invoked by uid 89); 16 Apr 2018 19:51:23 -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,SPF_PASS autolearn=ham version=3.3.2 spammy=H*c:HHHHH X-HELO: mta-p5.oit.umn.edu Received: from mta-p5.oit.umn.edu (HELO mta-p5.oit.umn.edu) (134.84.196.205) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Apr 2018 19:51:21 +0000 Received: from localhost (unknown [127.0.0.1]) by mta-p5.oit.umn.edu (Postfix) with ESMTP id A3ACD84D for ; Mon, 16 Apr 2018 19:51:19 +0000 (UTC) Received: from mta-p5.oit.umn.edu ([127.0.0.1]) by localhost (mta-p5.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ai9VRKPolm7r for ; Mon, 16 Apr 2018 14:51:19 -0500 (CDT) Received: from mail-it0-f72.google.com (mail-it0-f72.google.com [209.85.214.72]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p5.oit.umn.edu (Postfix) with ESMTPS id 7E6F290 for ; Mon, 16 Apr 2018 14:51:19 -0500 (CDT) Received: by mail-it0-f72.google.com with SMTP id v195-v6so8721137ita.1 for ; Mon, 16 Apr 2018 12:51:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=F2V7iBPeaZY1ajNvW9/vnB2Nldx6QD/YeOdF3/AxhWU=; b=tu3z/HAQ/mQXO83qV/ngrny+6MT/JETzeYx06dyh0BLmz8mqrFnMPvX3/4AHi8ZPAj lEBN6pfcdO88s1upLqBhZO8nJ8eF0qMMElzCJrkpUIY3lF7nhwh0spb1r5XtY55SrrB5 c5z6tx8P26ZIagjkJSlm1eyFKrmvcNtSHk2ce6Yq2P1M4Sd3KodZuiZxf7buBDNKN+oj dvVnACJfS/7x9hHNjXS532foNxIY8mXAnCBG61yfGAqpraTiPpOfoSmmeIYYHvCo49ZK llD4+yrAu/REojLV7DJN2s5FTWCj19u4GWeFE2e/jfV3bfb4srHW26XdW4QYUHLObufh JeJg== X-Gm-Message-State: ALQs6tDLMCfBDUmN1zy6gaA8OUYZCmkj9JWI3SBh/TiaHtlaqizE2s06 J0Xp+JI+LQWsZZapnaxe8YyfuKhszxcq7u8ADg2hyC+bJtK1G1LK097rOhnfUVOexzb7Dp5Qj9V qTc03gEDidLNRBafa X-Received: by 2002:a24:f587:: with SMTP id k129-v6mr6817734ith.95.1523908278828; Mon, 16 Apr 2018 12:51:18 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/J9kuEoVf2dX9e/W4tls8GPoI4v0+eSZFRIr+VQt9TMCCi8HP1Sb0TNhiHMs6Zqdnl4Z8C7w== X-Received: by 2002:a24:f587:: with SMTP id k129-v6mr6817709ith.95.1523908278530; Mon, 16 Apr 2018 12:51:18 -0700 (PDT) Received: from [2607:ea00:107:3c02:2c0c:98d3:8d99:1aea] ([2607:ea00:107:3c02:2c0c:98d3:8d99:1aea]) by smtp.gmail.com with ESMTPSA id v128-v6sm4757605itg.14.2018.04.16.12.51.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Apr 2018 12:51:18 -0700 (PDT) Date: Mon, 16 Apr 2018 19:51:00 -0000 From: "Ryan S. Elliott" To: Thomas Koenig cc: fortran@gcc.gnu.org Subject: Re: Darwin linker error "illegal text-relocation" with -shared In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (OSX 202 2017-01-01) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="0-2083095046-1523908277=:40373" X-IsSubscribed: yes X-SW-Source: 2018-04/txt/msg00085.txt.bz2 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --0-2083095046-1523908277=:40373 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8BIT Content-length: 1222 On Mon, 16 Apr 2018, Thomas Koenig wrote: > OK, so I haven't played around with shared libraries a lot. > >> In other words, the -c flag overrides the -shared flag.  This is not what I >> want.  I want to create a shared library which is done by the linker. > > When I run "gfortran -shared foo.f90" on Linux, I get > > /usr/bin/ld: /tmp/ccixEBK9.o: relocation R_X86_64_32 against `.rodata' can > not be used when making a shared object; recompile with -fPIC > /usr/bin/ld: final link failed: Nonrepresentable section on output > collect2: Fehler: ld gab 1 als Ende-Status zurück > > whereas "gfortran -shared -fPIC foo.f90" works. > > Is it advisable to compile a shared library without position-independent > code? > No, you are right. I should have included the -fPIC flag, but this doesn't change the results: $ gfortran-7 -shared -fPIC foo.f90 ld: illegal text-relocation to '_gee' in /var/folders/q0/mth73zrd307d66c43f8r3xv80000gp/T//ccG1nHc0.o from 'lC0' in /var/folders/q0/mth73zrd307d66c43f8r3xv80000gp/T//ccG1nHc0.o for architecture x86_64 collect2: error: ld returned 1 exit status As indicated in the subject linek, this is only an issue on macOS (Darwin), it all works just fine on linux... Ryan --0-2083095046-1523908277=:40373--