From owner-svn-src-head@freebsd.org Wed Oct 2 17:18:19 2019 Return-Path: Delivered-To: svn-src-head@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 C32E21349D8; Wed, 2 Oct 2019 17:18:19 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46k2sR4vSfz3FWg; Wed, 2 Oct 2019 17:18:19 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8C7DB2EBD6; Wed, 2 Oct 2019 17:18:19 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x92HIJFv085721; Wed, 2 Oct 2019 17:18:19 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x92HIJ8o085719; Wed, 2 Oct 2019 17:18:19 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910021718.x92HIJ8o085719@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 2 Oct 2019 17:18:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353019 - head/share/mk X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/share/mk X-SVN-Commit-Revision: 353019 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Oct 2019 17:18:19 -0000 Author: kevans Date: Wed Oct 2 17:18:18 2019 New Revision: 353019 URL: https://svnweb.freebsd.org/changeset/base/353019 Log: Override the TLS model when building mips64 binaries and static libraries GCC uses "dynamic" TLS models when -fpic or -fPIC is explicitly specified on the command line (which is only true for shared libraries). It uses "static" (or "exec") TLS models otherwise. In particular, GCC does _not_ use dynamic TLS models when PIC is implicitly enabled (which it is on MIPS), only if a PIC flag is explicitly provided. llvm uses "dynamic" TLS models if PIC is enabled either via a PIC flag or if it is implicily enabled (as on MIPS64). This means that llvm on MIPS64 always uses "dynamic" TLS models. However, dynamic TLS models do not work for static binaries and libraries as the __tls_get_addr function they invoke is only defined in rtld. Written by: jhb Reviewed by: arichardson Differential Revision: https://reviews.freebsd.org/D21699 Modified: head/share/mk/bsd.lib.mk head/share/mk/bsd.prog.mk Modified: head/share/mk/bsd.lib.mk ============================================================================== --- head/share/mk/bsd.lib.mk Wed Oct 2 17:15:38 2019 (r353018) +++ head/share/mk/bsd.lib.mk Wed Oct 2 17:18:18 2019 (r353019) @@ -92,6 +92,12 @@ CXXFLAGS+= ${DEBUG_FILES_CFLAGS} CTFFLAGS+= -g .endif +# clang currently defaults to dynamic TLS for mips64 object files without -fPIC +.if ${MACHINE_ARCH:Mmips64*} && ${COMPILER_TYPE} == "clang" +STATIC_CFLAGS+= -ftls-model=initial-exec +STATIC_CXXFLAGS+= -ftls-model=initial-exec +.endif + .include # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries Modified: head/share/mk/bsd.prog.mk ============================================================================== --- head/share/mk/bsd.prog.mk Wed Oct 2 17:15:38 2019 (r353018) +++ head/share/mk/bsd.prog.mk Wed Oct 2 17:18:18 2019 (r353019) @@ -82,6 +82,11 @@ TAG_ARGS= -T ${TAGS:[*]:S/ /,/g} LDFLAGS+= -static .endif +# clang currently defaults to dynamic TLS for mips64 binaries +.if ${MACHINE_ARCH:Mmips64*} && ${COMPILER_TYPE} == "clang" +CFLAGS+= -ftls-model=initial-exec +.endif + .if ${MK_DEBUG_FILES} != "no" PROG_FULL=${PROG}.full # Use ${DEBUGDIR} for base system debug files, else .debug subdirectory