Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rG8qh-00DwUJ-Ou for pgsql-bugs@arkaria.postgresql.org; Thu, 21 Dec 2023 02:31:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rG8qg-0024uC-D7 for pgsql-bugs@arkaria.postgresql.org; Thu, 21 Dec 2023 02:31:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rG8qf-0024s5-VH for pgsql-bugs@lists.postgresql.org; Thu, 21 Dec 2023 02:31:46 +0000 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rG8qb-00BQat-UL for pgsql-bugs@lists.postgresql.org; Thu, 21 Dec 2023 02:31:44 +0000 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-6d93d15db24so334983b3a.0 for ; Wed, 20 Dec 2023 18:31:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703125900; x=1703730700; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=FaFMUZt5aTRG6MAdo1EEgn4eWb8a4JgA1DJDCU4S4fU=; b=O8zE5NFKsZD94wbcNdLu3kDoVBI8YckO/00T6Dv2g3FoeRoWcHhpHG4uXfqPcgESPA t7xc6KLpERkb0z/sq+R150mwwPq8uNduh/hmW/e48VwK36IexxFWxFyl8rugyE78t/Jv Lq8U8iPbr3zaC0SBAMpeH91IRMZOOYSdno6M2yNWoXUt9QLaGJ+o72WyatMrJ2XAezmr KIMVG/EWasOKl+eivhG/xIBWYGMr8ReZQe1ZLxxMaB3GTwS58trUZmw9Eie5wc1Qk1X6 E+nRn0oeKc+aM6QNv1+z1qVycFGSRFJARBLFfE6qPa+BOxpkoJ6KrUmg5yXR7O0Wl/52 URCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703125900; x=1703730700; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FaFMUZt5aTRG6MAdo1EEgn4eWb8a4JgA1DJDCU4S4fU=; b=UdTrxVF+PPUo9OvXMx+a7BN6O098NwmKohKNzcbdwk6gC7/qbj/OMwhxw3mHJGeCNz 1QU3UVY8+vVazyqnawHAa/4eGk5v2lfJ4/+oaULu1f49fUA9olN+WNhDRrn/XQc6239Y f0Z70LxlVQ6Xw74FVkA0vJp8zPTK/E+fbP27ae6RLMB9DUjl8KaF8UlTNars+pfP02h4 vXRmsWUTnXuHHSkyBYjqd/fENuhkqi499fRYUejbz26y7XLvuVPooWoknon0IGh7m8qB ZRPMHjfUq9DrN2X7GQg4vW7HTkhgLwZdDHZpnp3cCkwrEJ8jYMbNGOdtXW/UfAqBqu/C Xafw== X-Gm-Message-State: AOJu0YxYAlRhmolfwUO70DfzEECcVfHAfyAi5ytLTZywv+cGDJHeN92Q Y9hoo+ek5xqEfLcAZaX3tbg= X-Google-Smtp-Source: AGHT+IFANlDgja/AAdKGK7qIUVbTKbN1wX2KTImrkvpHqHlukR1XxvSwcPv+/RjWeJikcw6nfB3BRQ== X-Received: by 2002:a05:6a00:9390:b0:6d9:96d:81f5 with SMTP id ka16-20020a056a00939000b006d9096d81f5mr5961681pfb.15.1703125900392; Wed, 20 Dec 2023 18:31:40 -0800 (PST) Received: from [192.168.10.115] ([58.32.6.36]) by smtp.gmail.com with ESMTPSA id 5-20020aa79245000000b006d9361fcfc8sm450358pfp.177.2023.12.20.18.31.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Dec 2023 18:31:40 -0800 (PST) Message-ID: Date: Thu, 21 Dec 2023 10:31:37 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: =?UTF-8?Q?Re=3A_BUG_=2318254=3A_could_not_load_library_llvmjit=2Eso?= =?UTF-8?Q?=EF=BC=8CUndefined_symbol_=22=5FZN4llvm12MemoryBuffer7getFileERKN?= =?UTF-8?Q?S=5F5TwineEbbbSt?= Content-Language: en-US To: Thomas Munro , pgsql-bugs@lists.postgresql.org References: <18254-e303b33b2317c861@postgresql.org> From: Xiaoming In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I got the reason, why not found the symbol. On my FreeBSD system, I have 2 version clang++, the system path `/usr/bin/clang++` and the `pkg` version `/usr/local/bin/clang++16`. When I just only set the environment `LLVM_CONFIG=llvm-config16`, run `./configure --prefix=/usr/local --with-openssl --with-lz4 --with-wal-blocksize=64 --with-blocksize=32 --with-llvm` out put this configure result: ```text configure: using compiler=FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152) configure: using CFLAGS=-Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Werror=unguarded-availability-new -Wendif-labels -Wmissing-format-attribute -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-unused-command-line-argument -Wno-compound-token-split-by-macro -Wno-cast-function-type-strict -I/usr/local/include/python3.11/ configure: using CPPFLAGS= -I/usr/local/include configure: using LDFLAGS= -L/usr/local/llvm16/lib -L/usr/local/lib  -Wl,--as-needed configure: using CXX=/usr/bin/clang++ configure: using CXXFLAGS=-Wall -Wpointer-arith -Werror=unguarded-availability-new -Wendif-labels -Wmissing-format-attribute -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 configure: using CLANG=/usr/bin/clang configure: using BITCODE_CFLAGS= -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Xclang -no-opaque-pointers -Wno-unused-command-line-argument -Wno-compound-token-split-by-macro -O2 configure: using BITCODE_CXXFLAGS= -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Xclang -no-opaque-pointers -O2 ``` I changed the environments: ```bash export LLVM_CONFIG=/usr/local/bin/llvm-config16 export CC=/usr/local/bin/clang16 export CXX=/usr/local/bin/clang++16 export CLANG=/usr/local/bin/clang16 ``` configure out put: ```text configure: using compiler=clang version 16.0.6 configure: using CFLAGS=-Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Werror=unguarded-availability-new -Wendif-labels -Wmissing-format-attribute -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-unused-command-line-argument -Wno-compound-token-split-by-macro -Wno-cast-function-type-strict -I/usr/local/include/python3.11/ configure: using CPPFLAGS= -I/usr/local/include configure: using LDFLAGS= -L/usr/local/llvm16/lib -L/usr/local/lib  -Wl,--as-needed configure: using CXX=/usr/local/bin/clang++16 configure: using CXXFLAGS=-Wall -Wpointer-arith -Werror=unguarded-availability-new -Wendif-labels -Wmissing-format-attribute -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 configure: using CLANG=/usr/local/bin/clang16 configure: using BITCODE_CFLAGS= -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-unused-command-line-argument -Wno-compound-token-split-by-macro -O2 configure: using BITCODE_CXXFLAGS= -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2  ``` This issue may be reason with the system path clang++ pair of `pkg` version llvm libraries. On the FreeBSD system, if with the `--with-llvm` configure argument, should build with the llvm's clang and clang++. I guess the system path `/usr/bin/clang++` has some difference with `pkg` version `/usr/local/bin/clang++16`, or `LD_LIBRARY_PATH` not contained the real `/usr/local/llvm16/lib` path. My new build version, it's work well. ```text ... Planning Time: 2.444 ms JIT:     Functions: 75     Options: Inlining true, Optimization true, Expressions true, Deforming true     Timing: Generation 3.608 ms, Inlining 248.625 ms, Optimization 208.667 ms, Emission 167.912 ms, Total 628.812 ms Execution Time: 10882.537 ms ``` On 2023/12/21 05:02, Thomas Munro wrote: > On Thu, Dec 21, 2023 at 9:31 AM PG Bug reporting form > wrote: >> ERROR: could not load library "/usr/local/lib/postgresql/llvmjit.so": >> /usr/local/lib/postgresql/llvmjit.so: Undefined symbol >> "_ZN4llvm12MemoryBuffer7getFileERKNS_5TwineEbbbSt8optionalINS_5AlignEE" >> Demangle the symbol >> `_ZN4llvm12MemoryBuffer7getFileERKNS_5TwineEbbbSt8optionalINS_5AlignEE` is >> `llvm::MemoryBuffer::getFile(llvm::Twine const&, bool, bool, bool, >> std::optional)` > My OS and LLVM (installed with pkg) are the same as yours, > though I'm building the master branch of PostgreSQL... hmm, I see a > slightly different name here: > > tmunro@build1:~/projects/postgresql $ nm -DC > ~/install/lib/postgresql/llvmjit.so | grep > 'llvm::MemoryBuffer::getFile' > U llvm::MemoryBuffer::getFile(llvm::Twine const&, > bool, bool, bool, std::__1::optional)@LLVM_16 > > tmunro@build1:~/projects/postgresql $ nm -DC > /usr/local/llvm16/lib/libLLVM.so | grep > 'llvm::MemoryBuffer::getFile(llvm::Twine' > 00000000038ba2d0 T llvm::MemoryBuffer::getFile(llvm::Twine const&, > bool, bool, bool, std::__1::optional)@@LLVM_16 > > Note "std::__1::optional". Could this be a clue about C++ standard > library mismatch, or something like that? Google is telling me that > stdlib=libc++ (LLVM's standard library) has the __1 namespace, but > stdlib=libstdc++ (GNU's standard library) lacks it, but I didn't look > too hard...