From nobody Mon Dec 22 09:31:46 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4dZXw25FQbz6Khxd for ; Mon, 22 Dec 2025 09:31:46 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dZXw24Rydz4DkQ for ; Mon, 22 Dec 2025 09:31:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1766395906; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ahOJKM2A/q0iLIZntKoNaKUDvXgxpfKv3btr3DZjEVM=; b=ajmTfL9IBQ0PSeKCKkHkKVXpvMbhv2dJOgV7+v76Y7kNzX46u52+c5KoLl4h05bOi2Iezs fAigEQlt5HLNJ/SSiA8N3gjT82FqN3nw5t9b6F+A40jp6Yt/2uVVMLipqv0lH/zGZTPazL Vzg8IWe4qhXwo3PhMsBR2kqkq3xpXk+g81zO64M3Eg2GNRWToP2ML8/YlVLv8bcv7OJ6s+ BwcS3FKGoB6mfc4VIg9V/q0963Sbc89Cd2DjmwdOCLHOo7pe3u0DpCyaQU6tZF66+ACK19 dsavErKAnEM7t90EsYnUNVjjBXJXHXwkumYlpXuxT3i3mwzfjzjKGd8OdYE9bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1766395906; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ahOJKM2A/q0iLIZntKoNaKUDvXgxpfKv3btr3DZjEVM=; b=H8yoGiC9XgVv8M4Ztysw5pGDMFdR+rK946FZ1h8jbAqg0079H3vOFM5Ow+GDYDG/vVWBsS 9KhOQROoZN5Qs1seUvAJYyve+Y773YMjENRaKyW/j/ClFoGsjPA37IgobjLz2m+9X++TdU qrzvUpX7Q19VJHUOZigWPOffB/MxrFsXhKC3F2Bs8uf2meCteSJE09gF6mYqMArLeA18M0 +TdoZ+8AP/EvqKrX5IDLZsFMc866/vpItok2siBhFe0s+1qMVwffXafsqMabnYcfCngnG9 7/uFRDiyNFGxP221H9ik5uRzF1LGx4RZsfexeggjfAtWUtkFETXCtmnBVb2pzg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1766395906; a=rsa-sha256; cv=none; b=AXVkj1f7opHpLZwnzy0t8NfCk0S6E4BW3Lea9Nae2cGb5gOQatV7+X4eRl1fV9TDUvMqbu +eweZl+2zhYezQpWVQQ9sO5+JYwa1KfVLKKo++8Idys9gKEapuCE5o9LI2G3xt1lP5YW4/ PBUBGLuaAXPOJXaGzSahtCf5vOJ8wKrotZWRObyKWkON3sXqMDeh6L/LbYcDCPY7tTDzj4 aNl29PHiIeLQJ9xxn2RCNirdbhACW5b6pW40lKoQoBghOXteyRFg9RY3Ov9ndm5llJZke9 WnJV1dfMd/e3goHF2NhBf0Y33DShUT5XBBiyeLUEzzNraXOP1yxId67GkJSv8A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dZXw242j1z4wS for ; Mon, 22 Dec 2025 09:31:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 90be by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 22 Dec 2025 09:31:46 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: cf1eaaf41cef - main - Reduce number of external symbols in libllvm, libclang and liblldb List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cf1eaaf41cefe7e3aef45f6dab862191a3939ed8 Auto-Submitted: auto-generated Date: Mon, 22 Dec 2025 09:31:46 +0000 Message-Id: <69491002.90be.d40a7f8@gitrepo.freebsd.org> The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=cf1eaaf41cefe7e3aef45f6dab862191a3939ed8 commit cf1eaaf41cefe7e3aef45f6dab862191a3939ed8 Author: Dimitry Andric AuthorDate: 2025-12-21 21:37:57 +0000 Commit: Dimitry Andric CommitDate: 2025-12-22 09:31:40 +0000 Reduce number of external symbols in libllvm, libclang and liblldb In commit 2e47f35be5dc libllvm, libclang and liblldb were converted into private shared libraries. This allowed clang, lld, lldb, and other llvm tools to be linked against these shared libraries, which makes them smaller and avoids duplication. However, upstream builds the shared libraries using several visibility options, which reduces the number of external symbols, and makes the libraries a bit smaller. On my test machine: * libprivatellvm.so goes from 75643 to 34706 symbols (~54% reduction) * libprivateclang.so goes from 53250 to 33531 symbols (~37% reduction) * libprivatelldb.so goes from 27242 to 18798 symbols (~31% reduction) Note: to get the full benefit, a clean build is required. Incremental builds should still work, but I didn't want to force a full rebuild on everybody. MFC after: 1 week --- lib/clang/libllvm/Makefile | 12 ++++++++++++ lib/clang/llvm.build.mk | 1 + 2 files changed, 13 insertions(+) diff --git a/lib/clang/libllvm/Makefile b/lib/clang/libllvm/Makefile index 810eac08d8d5..7c45375b8fbf 100644 --- a/lib/clang/libllvm/Makefile +++ b/lib/clang/libllvm/Makefile @@ -48,6 +48,8 @@ CFLAGS+= -DBLAKE3_NO_AVX512 -DBLAKE3_NO_AVX2 -DBLAKE3_NO_SSE41 \ CFLAGS+= -DBLAKE3_USE_NEON=0 .endif +CFLAGS+= -DLLVM_BUILD_LLVM_DYLIB + SRCDIR= llvm/lib # Explanation of different SRCS variants below: @@ -2050,6 +2052,16 @@ SRCS_ALL+= ${SRCS_COV} SRCS+= ${GENSRCS} SRCS+= ${SRCS_ALL:O} +# Optimization: for all source files under Target/*/*, use -fvisibility=hidden, +# which reduces the number of external symbols in the resulting shared library. +# This is also what upstream does. +.for src in ${SRCS} +. if "${src:MTarget/*/*}" +CFLAGS.${src:T}+= -fvisibility=hidden +.info ${src}: CFLAGS.${src:T} +. endif +.endfor + llvm/CodeGen/GenVT.inc: ${LLVM_SRCS}/include/llvm/CodeGen/ValueTypes.td ${LLVM_MIN_TBLGEN} -gen-vt \ -I ${LLVM_SRCS}/include -d ${.TARGET}.d -o ${.TARGET} \ diff --git a/lib/clang/llvm.build.mk b/lib/clang/llvm.build.mk index a26e15679242..b8b4be7dfe28 100644 --- a/lib/clang/llvm.build.mk +++ b/lib/clang/llvm.build.mk @@ -122,6 +122,7 @@ LDFLAGS+= -Wl,-m,elf64lriscv_fbsd CXXSTD= c++17 CXXFLAGS+= -fno-exceptions CXXFLAGS+= -fno-rtti +CXXFLAGS+= -fvisibility-inlines-hidden .if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING) CXXFLAGS.clang+= -stdlib=libc++ .else