Problem installing libcxx and libcxxabi using Bootstrapping on Amazon Linux 2

Hi.

I’m trying to build and install libcxx and libcxxabi using the Bootstrapping method on Amazon Linux 2. Both ibcxx and libcxxabi libraries are prerequisites to build and install a plv8 extension which is my ultimate objective.

While doing the build of plv8 I’m getting below error:

Sounds like /usr/local/lib/x86_64-unknown-linux isn't on your linker search path.

How to make it available in the linker search path? Do I need to give some specific parameters to cmake during configure?

Thanks!

CMake would search /usr/local prefix by default, but alas plv8 seems to use Makefiles. Sticking "-L/usr/local/lib/x86_64-unknown-linux" here (<https://github.com/plv8/plv8/blob/r3.1alpha/Makefile#L166>) might be sufficient. It might be easier to simply use libstdc++ though.

Thanks. I understand what is SHLIB_LINK from here: https://github.com/postgres/postgres/blob/master/src/Makefile.shlib#L23

Do you mean to replace

SHLIB_LINK += -lrt -std=c++14 -lc++ (<https://github.com/plv8/plv8/blob/r3.1alpha/Makefile#L166>)
with
SHLIB_LINK += -L/usr/local/lib/x86_64-unknown-linux

Also, could you please elaborate what is meant by “It might be easier to simply use libstdc++ though”

Thanks again!

I rather meant appending. I'd imagine plv8 might require linking rt and the explicit standard flag.

> Also, could you please elaborate what is meant by "It might be easier to simply use libstdc++ though"

Presumably Amazon Linux uses libstdc++. Instead of using libc++ for plv8 and having to compile it, install it and make sure everything else is built with it too, you could simply use the system's (i.e. remove the -lc++).

Appending -L is giving same error:

SHLIB_LINK += -lrt -std=c++11 -lc++ -L/usr/local/lib/x86_64-unknown-linux

Appending -L is giving same error:

Is libc++.so.1.0 actually in the folder /usr/local/lib/x86_64-unknown-linux?
Where is ld searching (-v)?

> Below is also giving above error i.e. "make: /usr/bin/opt: Command not found"

I guess plv8 also requires opt, so also build that. Since you are installing /usr/local you may need to override LLVM_BINPATH that plv8 uses. It's unclear to me how it's set or derived by default.

ls /usr/local/lib/x86_64-unknown-linux | grep -i libc++.so.1.0

libc++.so.1.0

ldd -v /usr/local/lib/x86_64-unknown-linux/libc++.so.1.0 | grep -i libc++.so.1.0

/usr/local/lib/x86_64-unknown-linux/libc++.so.1.0:

I can try with opt. Can you provide some reference on building opt on Linux?

To override LLVM_BINPATH, do I need to install llvm-config and then override something like “LLVM_BINPATH=$LLVM_CONFIG --bindir” ?

Thanks!

# ls /usr/local/lib/x86_64-unknown-linux | grep -i libc++.so.1.0

I presume the symlinks from libc++.so to libc++.so.1 to libc++.so.1.0 also exist?

> I can try with opt. Can you provide some reference on building opt on Linux?

It's part of LLVM so it should suffice to add "llvm" to LLVM_ENABLE_PROJECTS.

> To override LLVM_BINPATH, do I need to install llvm-config and then override something like "LLVM_BINPATH=$LLVM_CONFIG --bindir" ?

It's unclear to me how plv8 sets LLVM_BINPATH and whether providing it as an environment variable would suffice.
You could simply hardcode the path here (<https://github.com/plv8/plv8/blob/821f1638934e3f0ad4c979de442d6cb74f1e32e9/Makefile.shared#L119>).

I think one symlink is missing i.e. from to libc++.so → libc++.so.1.0

I think one symlink is missing i.e. from to libc++.so --> libc++.so.1.0

Indeed. Unless libc++.so is actually a linker script, though I don't believe libc++ does that.

> It's not clear what would be the path of LLVM_BINPATH?

Wherever your opt is located.

Indeed. Unless libc++.so is actually a linker script, though I don’t believe libc++ does that.
Ok. I’ll try to symlink the way you mentioned previously and will try again.

Meanwhile, I’ve tried to build and install along with " -DLLVM_ENABLE_PROJECTS=“clang;llvm”, but still when I type clang and/or opt in terminal I get “-bash: opt: command not found”

cmake -G Ninja -S llvm -B build -DLLVM_ENABLE_PROJECTS=“clang;llvm” -DLLVM_ENABLE_RUNTIMES=“libcxx;libcxxabi” -DLLVM_PARALLEL_LINK_JOBS=1 -DCMAKE_BUILD_TYPE=Release

Is “opt” a dir or library?

Thanks!

but still when I type clang and/or opt in terminal I get "-bash: opt: command

not found"

Make sure where they're located or installed to is on your PATH.

> Is "opt" a dir or library?

A tool, i.e. an executable.

Hello!

Tried creating a symlink, but unfortunately getting the same error.

Tried creating a symlink, but unfortunately getting the same error.

Then it sounds like /usr/local/lib/x86_64-unknown-linux still isn't on ld's search path. Run the faulty linker command -v, which should print a bunch of info including the search paths.

> (after doing "ninja-build -C build install-runtimes") ??

install-runtimes only installs the runtimes (libc++, libc++abi and libunwind in your case). Use the regular install target for the rest.

“ldconfig -v” gives a huge output, so I’ve made it available via the link below: It looks like path is available to ld.

https://drive.google.com/file/d/1iXZdvqmgNCs9My-CY-7VlkvKeYaeuSAG/view?usp=sharing

Let me know if you can’t see?

Please don’t get confuse between “/usr/local/lib/x86_64-unknown-linux-gnu” and “/usr/local/lib/x86_64-unknown-linux” the difference of “-gnu” is because when I don’t give "-DLLVM_RUNTIME_TARGETS=“x86_64-unknown-linux” in cmake configure, then “-gnu” get added by cmake. So I know this and I’ve stopped giving “”-DLLVM_RUNTIME_TARGETS=“x86_64-unknown-linux”.

Thanks!

"ldconfig -v" gives a huge output, so I've made it available via the link

below: It looks like path is available to ld.

ldconfig outputs info about the dynamic linker's search patch. ld doesn't use that. ld's search patch is the one you're interested in.

Sorry, my bad!

Full output of “d -v” is here: https://drive.google.com/file/d/15okn-FtCFGE21iNVgSb5JIoCertATDeo/view?usp=sharing

ld.so.conf is only for the dynamic linker not lld/ld.

you need to add it with -L<path> in LDFLAGS or similar.