From nobody Mon Dec 29 02:12:11 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 4dffqc2S1Qz6LVmc for ; Mon, 29 Dec 2025 02:12:12 +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 4dffqc1Grhz3hRJ for ; Mon, 29 Dec 2025 02:12:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1766974332; 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=rGKlmmXP6dB5RqgDmA1PBARxSPzwAYaH+PzDChgUCmQ=; b=uoFV9FKAUaUQuyjLlXHa899G3pzoxdJtxZUfxFsBlrUNthHekcx8pZdQ/NJZWmyczUXSQx YKaw1rET+0BMFjImzDgOzikiAdF6mhew/ukIGMe+Oi6Ykjdk+xfYqvscWXCc1W/ueAdQez p2dSYZNRljvdY7qlt9fT5owpmLdI/QqLss2UOfW5GByhO451TWeRFm/oK1sgmLSLuQwitd DSeQvM5yNVgXEyrI/t4MguGKXZI1liFRgiixJU3/i3nlF6AEPYPzHdZVpWNReQPfRLtKHD ohOcbG0KUFPVEkjMj/bLvlXa/jf3WDr9mCnFwcix5MgW6DsH5wJ5HFRhqFihmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1766974332; 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=rGKlmmXP6dB5RqgDmA1PBARxSPzwAYaH+PzDChgUCmQ=; b=TWEzlyRcvVCb5Ls3ZLVbBUIbn+ZiXyJwFSeIHyqHkYocyAhBOVemmVLcWfZHutyLJQsHl+ IkZkg5OuWPns8anQukX8Ped66zaBq51icY9+QX0fCqQqLPY2w0NPBbSYfo0zYZZLRwxLoI qmbAH6yWCjoYz2DaDnE7LE59fWDLa69W7z4H3OoHsQPY7QCZcQR1A32ohHdbB5Z3yxPqPb C89vJlpVEk3EKh5oWH0/A1qtw6SXG1PaClbRlN1gsRTDy4Sfws307vlJHMKKPE9+Ym60YO dllmp2f4KvhHlpVCp7ywM+6WaeJq5FWKAxRnAkQ4f/wOU+2g4hwBr7Mj/t+z+g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1766974332; a=rsa-sha256; cv=none; b=UkPGEOhuLgtzvHRfviamjZq9KTuaw9AW5G3hQb286QGtWT8teYSMg/z0rlZOGsI3/HDJ7X lrjSYt7fOywJLPn2BujApDcWYyOYepqEgd+/KOrYD3NrlGif7usTIOmhJZRSS1YCKCvBYm hJRp7cW7Q54lQS9gHS0GzmahSoBnJvhn5QJMzkYw0G1arlsqIPGs9oifcZ4jqtqLsoTN+1 mweBayXjYQ18g279xgN2jpEpcFxuZiXm6kQQ6fqO55t96tSvAozGFwlqa1KldWNb9yju+s m+MV+qdTjeldBXzU3YH/+ZnjTV+BZ8vwDvkFLw0NiTZ6QocEZPG7MaHNhxXVlg== 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 4dffqb724cz19pJ for ; Mon, 29 Dec 2025 02:12:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3d9b4 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 29 Dec 2025 02:12:11 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 5c5e2a0a7be8 - stable/15 - 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/stable/15 X-Git-Reftype: branch X-Git-Commit: 5c5e2a0a7be849c7a557a026352008190f8bf10b Auto-Submitted: auto-generated Date: Mon, 29 Dec 2025 02:12:11 +0000 Message-Id: <6951e37b.3d9b4.33ba0388@gitrepo.freebsd.org> The branch stable/15 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=5c5e2a0a7be849c7a557a026352008190f8bf10b commit 5c5e2a0a7be849c7a557a026352008190f8bf10b Author: Dimitry Andric AuthorDate: 2025-12-21 21:37:57 +0000 Commit: Dimitry Andric CommitDate: 2025-12-29 02:09:11 +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 (cherry picked from commit cf1eaaf41cefe7e3aef45f6dab862191a3939ed8) --- 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 e88b2ff1033e..f6e51129e9fa 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