dharanad commented on issue #12316:
URL: https://github.com/apache/gluten/issues/12316#issuecomment-4736278263

   ## Suggested Fix
   
   The change is in `ep/build-velox/src/setup-ubuntu.sh` (the Gluten-maintained 
wrapper around Velox's Ubuntu setup script). Two modifications are needed:
   
   ### 1. Remove `libgflags-dev` from the apt install list
   
   In `install_velox_deps_from_apt`, remove `libgflags-dev` so the non-PIC apt 
package is never installed:
   
   ```diff
    function install_velox_deps_from_apt {
      ${SUDO} apt update
      ${SUDO} apt install -y \
        libc-ares-dev \
        libcurl4-openssl-dev \
        libssl-dev \
        libicu-dev \
        libdouble-conversion-dev \
        libgoogle-glog-dev \
        libbz2-dev \
   -    libgflags-dev \
        libgtest-dev \
        libgmock-dev \
   ```
   
   ### 2. Add `install_gflags` function and call it before `install_folly`
   
   Mirrors the pattern already used in `setup-centos8.sh` and 
`setup-openeuler24.sh`. Must be called **before** `install_folly` since Folly's 
cmake export bakes in the gflags library path at build time.
   
   ```diff
   +function install_gflags {
   +  # The apt-packaged libgflags.a is not compiled with -fPIC, which causes a
   +  # linker error when it is pulled into libvelox.so (a shared library).
   +  # Build from source with PIC enabled, matching what setup-centos8.sh does.
   +  ${SUDO} apt-get remove -y libgflags-dev || true
   +  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
   +}
   +
    function install_velox_deps {
      run_and_time install_velox_deps_from_apt
   +  run_and_time install_gflags
      run_and_time install_fmt
      run_and_time install_protobuf
      run_and_time install_grpc
      run_and_time install_boost
      run_and_time install_fast_float
      run_and_time install_folly
   ```
   
   ### Why this ordering matters
   
   Folly's installed cmake config 
(`/usr/local/lib/cmake/folly/folly-targets.cmake`) hardcodes the gflags library 
path at the time Folly is built. If `install_gflags` runs first and installs a 
PIC-compiled `libgflags.a` to `/usr/local/lib`, Folly will link against that 
version and export the correct path in its cmake targets. The subsequent 
`libvelox.so` link then resolves `gflags_static` to the PIC library and 
succeeds.
   
   ### Note on `libgoogle-glog-dev`
   
   `libgoogle-glog-dev` has `libgflags-dev` as an apt dependency. After the 
`apt-get remove` in `install_gflags`, glog headers (`glog/logging.h`) may be 
missing if they were only pulled in transitively. The existing 
`libgoogle-glog-dev` in `install_velox_deps_from_apt` (line 111) runs before 
`install_gflags`, so the headers are present during compilation. However, the 
`apt-get remove` in `install_gflags` may pull glog-dev out as well depending on 
apt's dependency resolution. A safe guard is to re-install it after:
   
   ```diff
    function install_gflags {
      ${SUDO} apt-get remove -y libgflags-dev || true
      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
   +  # Reinstall glog-dev in case apt removed it as a side effect of removing 
libgflags-dev
   +  ${SUDO} apt-get install -y libgoogle-glog-dev
    }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to