Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[VL][Ubuntu] Build fails linking libvelox.so: system libgflags.a not compiled with -fPIC

オープン 初心者向け
#12,316 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
74/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
bash, cmake, ubuntu
領域
build-system

調査の方向性

scripts/setup-ubuntu.sh の113行目から始め、依存関係の流れを setup-centos8.sh と setup-openeuler24.sh の install_gflags と比較してください。Folly のビルド前に Ubuntu の gflags インストール手順を追加し、その後 Ubuntu で動的な Velox ビルドを実行して、libvelox.so が非 PIC の libgflags.a エラーなしでリンクされることを確認してください。

索引モデルが issue の本文から書いたものです。

説明

Environment

  • OS: Ubuntu 22.04 (also affects Ubuntu 20.04)
  • Backend: Velox
  • Build type: Dynamic (non-vcpkg)

Problem

Building Gluten with the Velox backend on Ubuntu fails at the libvelox.so link step with:

/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libgflags.a(gflags.cc.o): relocation R_X86_64_PC32 against symbol 'stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status

Root Cause

scripts/setup-ubuntu.sh installs gflags via apt-get install libgflags-dev. The apt-packaged libgflags.a on Ubuntu is not compiled with -fPIC, so the linker rejects it when it is pulled into libvelox.so (a shared library).

The issue is in setup-ubuntu.sh:113:

libgflags-dev \   # <-- apt version is not PIC-compiled

Folly's installed cmake config (/usr/local/lib/cmake/folly/folly-targets.cmake) hardcodes gflags_static as a link dependency, which resolves to the non-PIC /usr/lib/x86_64-linux-gnu/libgflags.a.

Why Only Ubuntu

setup-centos8.sh and setup-openeuler24.sh both have a dedicated install_gflags function that:

  1. Removes the system package (dnf remove -y gflags)
  2. Builds gflags from source with cmake_install_dir gflags -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON

setup-ubuntu.sh is missing this function entirely.

Fix

Add an install_gflags function to setup-ubuntu.sh, mirroring what setup-centos8.sh does:

function install_gflags {
  # Remove apt version (not PIC-compiled, cannot be linked into shared libs)
  sudo apt-get remove -y libgflags-dev
  wget_and_untar https://github.com/gflags/gflags/archive/v2.2.2.tar.gz gflags
  cmake_install_dir gflags \
    -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
    -DBUILD_SHARED_LIBS=ON \
    -DBUILD_STATIC_LIBS=ON \
    -DBUILD_gflags_LIB=ON
}

And call it from install_dependencies before building Folly (since Folly's cmake export will then reference the PIC-compiled version).

Workaround

Until fixed, users on Ubuntu can manually build gflags with PIC before running the Gluten build:

sudo apt-get remove -y libgflags-dev
cd /tmp
wget https://github.com/gflags/gflags/archive/v2.2.2.tar.gz -O gflags.tar.gz
tar -xzf gflags.tar.gz && cd gflags-2.2.2
cmake -B build \
  -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
  -DBUILD_SHARED_LIBS=ON \
  -DBUILD_STATIC_LIBS=ON \
  -DBUILD_gflags_LIB=ON \
  -DCMAKE_INSTALL_PREFIX=/usr/local \
  -DCMAKE_BUILD_TYPE=Release
sudo cmake --build build -j4 --target install
# Reinstall glog-dev (removed as a side effect)
sudo apt-get install -y libgoogle-glog-dev

Note

Removing libgflags-dev also removes libgoogle-glog-dev as a side effect (apt dependency), causing a secondary glog/logging.h: No such file or directory error. The workaround above includes reinstalling libgoogle-glog-dev.

主要言語
Scala
スター
1.6k
フォーク
665
平均マージ
4日 1時間
マージ済み PR(30日)
93

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/gluten のほかの issue

apache/gluten の issue をすべて見る

似ている issue

Scala の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。