facebook / fbthrift

Facebook's branch of Apache Thrift, including a new C++ server.
Apache License 2.0
2.55k stars 608 forks source link

Ubuntu 20.04 cannot compile with __clang_major__>=9 #509

Closed zhengxingmao closed 1 year ago

zhengxingmao commented 2 years ago

Compile with error cpp2/protocol/Protocal.h:102 undefined reference to `$1' Any suggests ,thanks .

And here is my env: OS:==================== Distributor ID: Ubuntu Description: Ubuntu 20.04.4 LTS Release: 20.04 Codename: focal Clang:==================== clang version 9.0.1-12 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/10 Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/9 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9 Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/10 Candidate multilib: .;@m64 Selected multilib: .;@m64 GCC:============================== Using built-in specs. COLLECT_GCC=cc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none:hsa OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.4.0-1ubuntu1~20.04.1' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-Av3uEd/gcc-9-9.4.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1) G++:============================== root@hp:/workspace/IdeaProjects/presto/presto-native-execution# g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none:hsa OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.4.0-1ubuntu1~20.04.1' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-Av3uEd/gcc-9-9.4.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)

vitaut commented 2 years ago

Please provide full repro commands.

zhengxingmao commented 2 years ago

Thank you for your reply. I'm compiling presto_cpp project, which introduces the fbthrift library, reports this error when linking.

zhengxingmao commented 2 years ago

/usr/bin/ld: presto_cpp/main/thrift/libpresto_thrift-cpp2.a(presto_thrift_types.cpp.o): in function apache::thrift::detail::validate_bool(unsigned char)': /usr/local/include/thrift/lib/cpp2/protocol/Protocol.h:102: undefined reference to$1' collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed. make[1]: [Makefile:60:build] 错误 1 make[1]: 离开目录“/workspace/IdeaProjects/presto/presto-native-execution” make: [Makefile:64:debug] 错误 2

vitaut commented 1 year ago

Do you get this error when following build instructions from https://github.com/facebook/fbthrift#building?

zhengxingmao commented 1 year ago

Do you get this error when following build instructions from https://github.com/facebook/fbthrift#building?

Do you get this error when following build instructions from https://github.com/facebook/fbthrift#building?

No,i don't.The problem is compiling presto_cpp.Is the problem encountered in presto_cpp project adds special compilation options to identify ASM goto instructions ?

vitaut commented 1 year ago

Closing the issue then but feel free to reopen with a self-contained repro that doesn't involve other projects. One observation though is that line numbers are off: https://github.com/facebook/fbthrift/blob/main/thrift/lib/cpp2/protocol/Protocol.h#L102 which suggests that you are using an old version of thrift.

zhengxingmao commented 1 year ago

Yeah, I used v2022.03.14.00 version,and the error code ,The specific error location corresponding to the latest code is here:https://github.com/facebook/fbthrift/blob/5457f0b006f4a3413f6b5517a04bfc6b172fe57f/thrift/lib/cpp2/protocol/Protocol.h#L121

zhengxingmao commented 1 year ago

We have located the root cause: -msam=intel is specified in the compilation option, and the compilation will be normal after removal.Thank you for your answer.