microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
22.74k stars 6.29k forks source link

[folly] build failure #39938

Open diehard2 opened 1 month ago

diehard2 commented 1 month ago

Operating system

AlmaLinux 8.9

Compiler

GCC

I filed this failure last week, but it took me a little while to get a minimal reproducer. I couldn't figure out how to reopen the issue. This is with gcc and a pretty standard build setup. Thanks for any help

Steps to reproduce the behavior

Dockerfile

FROM almalinux:8.9

ARG DEBIAN_FRONTEND=noninteractive
ARG TZ=US/Central

RUN dnf update -y && dnf install -y epel-release && dnf config-manager --enable epel && dnf install -y yum-utils && dnf config-manager --set-enabled powertools && dnf install -y --allowerasing \
clang \
python3 \
cmake \
git \
ninja-build \
perl \
perl-IPC-Cmd \
numactl-devel \
binutils-devel

CMD ["bash"]

docker build . -t build_test docker run -it build_test


scl enable gcc-toolset-13 -- bash
vcpkg/vcpkg install folly


### Failure logs

FAILED: folly/logging/example/logging_example 
: && /opt/rh/gcc-toolset-13/root/usr/bin/c++ -fPIC -g -g -Wall -Wextra -rdynamic folly/logging/example/CMakeFiles/logging_example.dir/main.cpp.o -o folly/logging/example/logging_example  folly/logging/example/liblogging_example_lib.a  libfolly.a  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libfmtd.a  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libboost_context.a  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libboost_filesystem.a  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libboost_program_options.a  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libboost_thread.a  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libboost_atomic.a  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libboost_chrono.a  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libboost_system.a  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libboost_date_time.a  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libboost_container.a  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libboost_regex.a  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libboost_exception.a  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libdouble-conversion.a  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libglog.a  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libgflags_debug.a  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libevent_extrad.a  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libevent_pthreadsd.a  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libevent_cored.a  -lpthread  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libz.a  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libssl.a  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libcrypto.a  -pthread  -ldl  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libaio.a  -ldl  /vcpkg/vcpkg/installed/x64-linux/debug/lib/libaio.a && :
/opt/rh/gcc-toolset-13/root/usr/libexec/gcc/x86_64-redhat-linux/13/ld: libfolly.a(Demangle.cpp.o): in function `folly::demangle(char const*)':
/vcpkg/vcpkg/buildtrees/folly/src/4.07.08.00-142ec4b98b.clean/folly/Demangle.cpp:158: undefined reference to `cplus_demangle_v3_callback'
/opt/rh/gcc-toolset-13/root/usr/libexec/gcc/x86_64-redhat-linux/13/ld: libfolly.a(Demangle.cpp.o): in function `folly::demangle(char const*, char*, unsigned long)':
/vcpkg/vcpkg/buildtrees/folly/src/4.07.08.00-142ec4b98b.clean/folly/Demangle.cpp:226: undefined reference to `cplus_demangle_v3_callback'
/opt/rh/gcc-toolset-13/root/usr/libexec/gcc/x86_64-redhat-linux/13/ld: libfolly.a(Demangle.cpp.o):/vcpkg/vcpkg/buildtrees/folly/src/4.07.08.00-142ec4b98b.clean/folly/Demangle.cpp:96: undefined reference to `cplus_demangle_v3_callback'
collect2: error: ld returned 1 exit status

### Additional context

Can be fixed by linking libiberty.a directly. The following succeeds.

/opt/rh/gcc-toolset-13/root/usr/bin/g++ -fPIC -march=skylake -fPIC -march=skylake -g -g -Wall -Wextra -rdynamic folly/logging/example/CMakeFiles/logging_example.dir/main.cpp.o -o folly/logging/example/logging_example -L/usr/lib/clang/17/lib/x86_64-redhat-linux-gnu folly/logging/example/liblogging_example_lib.a libfolly.a /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libfmtd.a /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libboost_context.a /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libboost_filesystem.a /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libboost_program_options.a /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libboost_thread.a /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libboost_atomic.a /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libboost_chrono.a /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libboost_system.a /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libboost_date_time.a /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libboost_container.a /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libboost_regex.a /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libboost_exception.a /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libdouble-conversion.a /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libglog.a /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libgflags_debug.a /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libevent_extrad.a /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libevent_pthreadsd.a /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libevent_cored.a -lpthread /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libz.a /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libssl.a /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libcrypto.a -pthread -ldl /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libaio.a -ldl /home/dev/DDS/build/vcpkg_installed/x64-linux-clang/debug/lib/libaio.a -liberty
umartechboy commented 1 month ago

I am getting build errors with yasmtools x86, x64, cgal. It all worked half a month ago. Something done in the recent commits. Whatever I install, I get: error: building boost-headers:x64-windows failed with: BUILD_FAILEDSee https://learn.microsoft.com/vcpkg/troubleshoot/build-failures?WT.mc_id=vcpkg_inproduct_cli for more information. Elapsed time to handle boost-headers:x64-windows: 873 ms Please ensure you're using the latest port files with git pull and vcpkg update. Then check for known issues at: https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+boost-headers You can submit a new issue at: https://github.com/microsoft/vcpkg/issues/new?title=[boost-headers]+Build+error+on+x64-windows&body=Copy+issue+body+from+C%3A%2FUsers%2FAdministrator%2FDocuments%2FGitHub%2Fvcpkg%2Finstalled%2Fvcpkg%2Fissue_body.md

jimwang118 commented 1 month ago

Sorry, I still can't reproduce this problem locally, I only have Ubuntu locally.

diehard2 commented 1 month ago

thanks for looking at it @jimwang118. Since I have a really simple reproducer is there anyone else we could tag who can run a docker image and see the issue? This is a pretty standard image for RHEL based systems

diehard2 commented 1 month ago

@jimwang118

okay, I got folly building with an overlay port. The issue first came up in

https://github.com/microsoft/vcpkg/issues/25214#issuecomment-1154976112 in 2022

I found the solution in

https://github.com/microsoft/vcpkg/issues/35751


Now I fix it locally by add iberty into fix-deps.patch file:

-find_package(LibEvent MODULE REQUIRED)
-list(APPEND FOLLY_LINK_LIBRARIES ${LIBEVENT_LIB})
-list(APPEND FOLLY_INCLUDE_DIRECTORIES ${LIBEVENT_INCLUDE_DIR})
+find_package(Libevent CONFIG REQUIRED)
+list(APPEND FOLLY_LINK_LIBRARIES libevent::core libevent::extra)
+if(NOT WIN32)
+  list(APPEND FOLLY_LINK_LIBRARIES libevent::pthreads iberty)
+endif()

Is it possible to have this added to the port since

  1. It seems very innocuous
  2. it will let people using distros other than ubuntu build correctly
diehard2 commented 1 month ago

hmmmm, it will cause a build issue if binutils-devel isn't installed. Any ideas on a workaround?

diehard2 commented 1 month ago

okay, this works

+  list(APPEND FOLLY_LINK_LIBRARIES libevent::pthreads)
+  find_library(LIBIBERTY_LIBRARY NAMES libiberty.a)
+  if(LIBIBERTY_LIBRARY)
+    list(APPEND FOLLY_LINK_LIBRARIES iberty)
+  endif()

Interestingly, it appears that fix-deps is trying to do something with libiberty, but its not successful on redhat. maybe altering this line

@@ -132,17 +140,24 @@ find_package(Libiberty)
 list(APPEND FOLLY_LINK_LIBRARIES ${LIBIBERTY_LIBRARIES})
 list(APPEND FOLLY_INCLUDE_DIRECTORIES ${LIBIBERTY_INCLUDE_DIRS})

to what I have above will fix the issue

dg0yt commented 1 month ago

If you look at the old discussion... AFAIU the problem start's with folly's #if __has_include(<demangle.h>). Such checks too easily diverge from link lib tests.

diehard2 commented 1 month ago

@dg0yt I believe my patch will fix this for all cases. @jimwang118 is this something that can be added so that I don't have to maintain my own overlay port?

dg0yt commented 1 month ago
diehard2 commented 1 month ago

while it wouldn't fix every issue, it would fix at least some issues. maybe a message to install binutils-devel if the library is not found?

dg0yt commented 1 month ago

Not for Ubuntu (libiberty-dev).