From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id MM2zOh95AGOTvgAAbAwnHQ (envelope-from ) for ; Sat, 20 Aug 2022 08:03:12 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id ONiqOh95AGOJbwEAauVa8A (envelope-from ) for ; Sat, 20 Aug 2022 08:03:11 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id BDF5D2169E for ; Sat, 20 Aug 2022 08:03:11 +0200 (CEST) Received: from localhost ([::1]:50836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oPHZe-0007x6-NY for larch@yhetil.org; Sat, 20 Aug 2022 02:03:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oPHZG-0007wP-7n for guix-devel@gnu.org; Sat, 20 Aug 2022 02:02:48 -0400 Received: from mail-m972.mail.163.com ([123.126.97.2]:58038) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oPHZ5-0001mW-I1 for guix-devel@gnu.org; Sat, 20 Aug 2022 02:02:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=F1CQQ 274p7rrD2CYOZrmj8mAK2Kp0TyTkxtLkGoAP9A=; b=A3wJFiW5a5JsKJpbFFAKG 7a0X1KriHNBfFd7L+YCUtuxbfUF/IN0j9Nzsg1CxUqM2d0DjQhh8L6/B0J3AkQYf CmEvt7NZt1PoKzSl/Z8UY/BOAA+79r91sqwvqY3yKx6GTOk+x6Abz8momhfHfZzB WjoiXlPPozyb0k4qOlbHSI= Received: from asus-laptop (unknown [163.125.249.97]) by smtp2 (Coremail) with SMTP id GtxpCgDX9g7oeABj7J1JWw--.24422S2; Sat, 20 Aug 2022 14:02:17 +0800 (CST) User-agent: mu4e 1.6.10; emacs 27.2 From: Zhu Zihao To: Guix Devel Subject: [RFC] Use LLVM_BUILD_LLVM_DYLIB instead of BUILD_SHARED_LIBS Date: Wed, 20 Apr 2022 18:56:15 +0800 Message-ID: <867d33tpui.fsf@163.com> MIME-Version: 1.0 Content-Type: text/plain X-CM-TRANSID: GtxpCgDX9g7oeABj7J1JWw--.24422S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Ww1ktF4xWFWkJryxAw1fWFg_yoW8KFWUpF W2gF4Y9F1DuF1FvryxCa1UW34YgFsxXFW7XrWrG3yqkr1UXr97urykKFWYg3y7Z3s2yr4S vr98KFyDK3WfAa7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zRTv3OUUUUU= X-Originating-IP: [163.125.249.97] X-CM-SenderInfo: pdoosuxxwbztlvw6il2tof0z/xtbBLwpjr2HmoEeB3QAAsV Received-SPF: pass client-ip=123.126.97.2; envelope-from=all_but_last@163.com; helo=mail-m972.mail.163.com X-Spam_score_int: 18 X-Spam_score: 1.8 X-Spam_bar: + X-Spam_report: (1.8 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URI_NOVOWEL=0.5 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1660975391; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=F1CQQ274p7rrD2CYOZrmj8mAK2Kp0TyTkxtLkGoAP9A=; b=gQD/7TP1ZQ8LsD6TQNf1cWQghu7UIruB0woHcbPMQT9XU82o2IejEJ26Tm2NvrgD7g6bga cWcuRUeGRkq2ws9yqrTt1s5KmRzobP9JyndDTQZebiQwfC8TAzVsiMZgY28hXTXm7wnwYa 0yNGBnWjyj4SbaYJwvG++zGjDunMhuvHzG+YxHPUubAzAQehACjgK7ypRUGfyfxjxwBvVX gMTuPVFAD0MBxCHa0saSWsxNRGRGnJ05M1JrOeF9qp1PFP/G3vb2NSa6dpX19EKMAhq3ee W/Z9MXvUUdEv2QgW6RlhHGjDrHBYcxwk+Ji35288CutPWDn3PNYZhHwHSpxJWg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1660975391; a=rsa-sha256; cv=none; b=RXY3d/gZU/hC1B5FUsJVw11W3JYxQR9BvyoIyMzthm2WTL/MCrJP4/iVBAofKKhPBNm8cj Xwr+9HNIQqOTWz1hXDbmmmaCmaF23O/K3bXju7Z+TX6VAClzeQ4m2no5gG9AGELappAfFZ PepTE62Q+Y91+nM2z03cGRfU25UoAsdBIkr/lEsq2CQymqbO4uDQAaB3IXJTKfjvaBm00n zMn5UiKP4kwDRjMk/xntL9bCpTQiVL4zsmEzRmykyfTTgZeBDFrKX2eFLWkBcD5P4uYb/j ZpUZ0UWHYvfar8FSnshBQIDemtnZ8VqLpFOG+B8/u6DImvL3K86fEkxHzVjgZg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=163.com header.s=s110527 header.b=A3wJFiW5; dmarc=pass (policy=none) header.from=163.com; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -8.15 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=163.com header.s=s110527 header.b=A3wJFiW5; dmarc=pass (policy=none) header.from=163.com; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: BDF5D2169E X-Spam-Score: -8.15 X-Migadu-Scanner: scn0.migadu.com X-TUID: hfVrraWB53kP # Background Now in Guix. LLVM is built with configure flag "-DBUILD_SHARED_LIBS:BOOL=TRUE". According to https://llvm.org/docs/CMake.html. Build LLVM with `BUILD_SHARED_LIBS` is not recommended for non LLVM developing usage. LLVM says that packager should use `LLVM_BUILD_LLVM_DYLIB` instead. The main difference between `LLVM_BUILD_LLVM_DYLIB` and `BUILD_SHARED_LIBS` is the former one will generate a monolith shared library called `libLLVM.so` and the latter will generate individual libLLVMCore.so libLLVMXXX.so ... # Issue `BUILD_SHARED_LIBS` works for us now. But this configure flags will violates some setup of the cmake script of LLVM. LLVM components provides an cmake option called `LLVM_LINK_LLVM_DYLIB` to let user to choose whether dynamically linked or not. Our build breaks this option. In lib/cmake/llvm/AddOCaml.cmake:69 ``` if(LLVM_LINK_LLVM_DYLIB) list(APPEND ocaml_flags "-lLLVM") else() ``` If the add_ocaml_library function is used and `LLVM_LINK_LLVM_DYLIB` is set to true, it'll tries to link the libLLVM.so which is not provided by us. This issue also exists for add_llvm_library. Though this looks like the issue of LLVM, because `llvm-config` executable works well for us: if you pass `--link-static` to llvm-config, it will complain that static archive files is not found. And if pass `--link-shared`, it can generate the command args that link to individual shared library. # Solution I suggest to replace `-DBUILD_SHARED_LIBS:BOOL=TRUE` with `-DLLVM_BUILD_LLVM_DYLIB:BOOL=TRUE`. # Cons We may introduce following problems if we apply this solution. 1. Increase the closure size of LLVM. By default, if LLVM_BUILD_LLVM_DYLIB is set true, LLVM still tries to build the static archive. This may increase the closure size of LLVM. And some package linking with LLVM may use the static archive instead of linking to the dynamic library. My opinion: If we're OK with the bigger closure size, that's not a problem. If not, we may consider disable the static archive generation. For LLVM components, we can use `LLVM_LINK_LLVM_DYLIB` to ask these packages to link with the shared version. For package use `llvm-config` directly or indirectly, we can pass `--link-shared` to it. -- Retrieve my PGP public key: gpg --recv-keys D47A9C8B2AE3905B563D9135BE42B352A9F6821F Zihao