Skip to content

Commit e215b3b

Browse files
Stanislav Fomichevmeta-codesync[bot]
authored andcommitted
build_ncclx: fix libdwarf discovery by creating missing conda symlinks (#2397)
Summary: Pull Request resolved: #2397 Conda installs libdwarf with a versioned filename (e.g. `libdwarf.so.0.11.0`) but does not always create the unversioned `libdwarf.so` symlink that cmake / folly's FindLibDwarf expects. Add `ensure_conda_libdwarf_symlinks()` which locates the real versioned library, creates the `libdwarf.so` symlink, and also creates the SONAME symlink read from the ELF header. Call it right after `conda install` and before building folly so the build reliably finds libdwarf inside the conda environment. Reviewed By: function47 Differential Revision: D103062296 fbshipit-source-id: 59864e9785567052336f4316ce725eb8fc1a7a29
1 parent 0631785 commit e215b3b

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

build_ncclx.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,32 @@
33

44
set -x
55

6+
function ensure_conda_libdwarf_symlinks() {
7+
local conda_lib_dir="${CMAKE_PREFIX_PATH}/lib"
8+
local libdwarf_real=""
9+
local soname=""
10+
11+
for candidate in "${conda_lib_dir}"/libdwarf.so "${conda_lib_dir}"/libdwarf.so.*; do
12+
[[ -e "$candidate" ]] || continue
13+
if [[ -f "$candidate" && ! -L "$candidate" ]]; then
14+
libdwarf_real="$(basename "$candidate")"
15+
break
16+
fi
17+
done
18+
19+
if [[ -z "$libdwarf_real" ]]; then
20+
return
21+
fi
22+
23+
if [[ "$libdwarf_real" != "libdwarf.so" ]]; then
24+
ln -sf "$libdwarf_real" "${conda_lib_dir}/libdwarf.so"
25+
fi
26+
soname=$(readelf -d "${conda_lib_dir}/${libdwarf_real}" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\]/\1/p' | head -n 1)
27+
if [[ -n "$soname" && "$soname" != "$libdwarf_real" ]]; then
28+
ln -sf "$libdwarf_real" "${conda_lib_dir}/${soname}"
29+
fi
30+
}
31+
632
function do_cmake_build() {
733
local source_dir="$1"
834
local extra_flags="$2"
@@ -182,6 +208,7 @@ function build_third_party {
182208
fmt
183209
)
184210
conda install "${DEPS[@]}" --yes
211+
ensure_conda_libdwarf_symlinks
185212
build_fb_oss_library "https://github.com/facebook/folly.git" "$third_party_tag" folly
186213
fi
187214
fi

0 commit comments

Comments
 (0)