From owner-freebsd-questions@freebsd.org Wed Oct 16 11:44:33 2019 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8652B162923 for ; Wed, 16 Oct 2019 11:44:33 +0000 (UTC) (envelope-from markand@malikania.fr) Received: from smtp.smtpout.orange.fr (smtp06.smtpout.orange.fr [80.12.242.128]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (Client CN "Bizanga Labs SMTP Client Certificate", Issuer "Bizanga Labs CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 46tVnr4F5Cz4cYM for ; Wed, 16 Oct 2019 11:44:31 +0000 (UTC) (envelope-from markand@malikania.fr) Received: from postfix.malikania.fr ([5.135.187.121]) by mwinf5d63 with ME id EBkU2100B2dbEiD03BkUdQ; Wed, 16 Oct 2019 13:44:29 +0200 X-ME-Helo: postfix.malikania.fr X-ME-Auth: ZGVtZWxpZXIuZGF2aWRAb3JhbmdlLmZy X-ME-Date: Wed, 16 Oct 2019 13:44:29 +0200 X-ME-IP: 5.135.187.121 Received: from [167.3.108.158] (unknown [77.159.242.250]) by postfix.malikania.fr (Postfix) with ESMTPSA id 2067B2A2E6 for ; Wed, 16 Oct 2019 13:44:27 +0200 (CEST) Subject: Re: Problems with ld, libc, and "struct stat" To: freebsd-questions@freebsd.org References: <20191015204400.e33c8f62af711e829288ddae@magnetkern.de> <47c27361-4e74-05d1-3343-e39526730d85@malikania.fr> <20191016131552.6fda34292987e22ae78072cc@magnetkern.de> From: David Demelier Message-ID: <0f1c70a0-c99a-e494-cf63-d214301f24a1@malikania.fr> Date: Wed, 16 Oct 2019 13:44:25 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191016131552.6fda34292987e22ae78072cc@magnetkern.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 46tVnr4F5Cz4cYM X-Spamd-Bar: +++ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of markand@malikania.fr has no SPF policy when checking 80.12.242.128) smtp.mailfrom=markand@malikania.fr X-Spamd-Result: default: False [3.66 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; TO_DN_NONE(0.00)[]; AUTH_NA(1.00)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_THREE(0.00)[3]; RCVD_TLS_LAST(0.00)[]; NEURAL_SPAM_MEDIUM(0.99)[0.985,0]; NEURAL_SPAM_LONG(0.93)[0.928,0]; RCVD_IN_DNSWL_NONE(0.00)[128.242.12.80.list.dnswl.org : 127.0.5.0]; R_SPF_NA(0.00)[]; DMARC_NA(0.00)[malikania.fr]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:3215, ipnet:80.12.240.0/20, country:FR]; MID_RHS_MATCH_FROM(0.00)[]; IP_SCORE(0.84)[ip: (1.20), ipnet: 80.12.240.0/20(1.38), asn: 3215(1.64), country: FR(-0.00)]; RWL_MAILSPIKE_POSSIBLE(0.00)[128.242.12.80.rep.mailspike.net : 127.0.0.17] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Oct 2019 11:44:33 -0000 Le 16/10/2019 à 13:15, Jan Behrens a écrit : > Do you know any link where I find a more detailed explanation about why > I need to use "cc" instead of "ld" to create shared libraries? I assume > that "cc" adds the necessary options to "ld" that are otherwise > missing. But I don't see where this is documented. Yes, many :-) See output of clang -v when creating your shared library: "/usr/bin/ld" --eh-frame-hdr -Bshareable --hash-style=both --enable-new-dtags -o libfoo.so /usr/lib/crti.o /usr/lib/crtbeginS.o -L/usr/lib test.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtendS.o /usr/lib/crtn.o > When I search the man page for "cc" (clang - the Clang C, C++, and > Objective-C compiler), I even do not find any "-shared" option at all. -shared is a linker option, it's documented in gcc but basically clang is usually retro-compatible with most of the GCC option. In fact, -shared is just a shortcut to pass the appropriate shared arguments to the underlying linker in that case -Bshareable (but may add additional options as well). Clang's manual page is not as full as gcc, that's true though. Regards, -- David