Tests fail with LTO due to ODR / type mismatch violations
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp và boost/smart_ptr/detail/sp_counted_base_nt.hpp, so sánh các trường của sp_counted_base cùng các khai báo release, weak_release và destroy được GCC báo cáo. Tái hiện lỗi với các cờ LTO và -Werror được nêu, sau đó chạy các bài kiểm thử bị ảnh hưởng abi_test_mt_nt và abi_test_nt_mt; hoàn thành khi các bài kiểm thử này build thành công mà không có lỗi ODR và lỗi không khớp kiểu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I tried to build with the following *FLAGS to optimize the build: -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing
Link-Time Optimization is a massively global compiler optimization pass which is pretty handy for producing faster executables. It also has the interesting property that because the compiler does whole-program analysis using bytecode, it can save type information and perform error checks that it normally doesn’t have enough insight for. In particular, checking for ODR issues and checking function type signature mismatches.
Note that all the -Werror=* flags are used to help detect cases where the compiler tries to optimize by assuming UB cannot exist in the source code -- if it does exist, ordinarily the code would be miscompiled, and this says to make the miscompilation a fatal error.
I got this error:
gcc.link ../../../bin.v2/libs/smart_ptr/test/abi_test_mt_nt.test/gcc-14.3/gentoorelease/x86_64/pch-off/threading-multi/visibility-hidden/abi_test_mt_nt
"x86_64-pc-linux-gnu-g++" -Wl,-rpath -Wl,"/var/tmp/portage/dev-libs/boost-1.89.0/work/boost_1_89_0-abi_x86_64.amd64/bin.v2/libs/atomic/build/gcc-14.3/gentoorelease/x86_64/pch-off/threading-multi/visibility-hidden" -Wl,-rpath-link -Wl,"/var/tmp/portage/dev-libs/boost-1.89.0/work/boost_1_89_0-abi_x86_64.amd64/bin.v2/libs/atomic/build/gcc-14.3/gentoorelease/x86_64/pch-off/threading-multi/visibility-hidden" -o "../../../bin.v2/libs/smart_ptr/test/abi_test_mt_nt.test/gcc-14.3/gentoorelease/x86_64/pch-off/threading-multi/visibility-hidden/abi_test_mt_nt" -Wl,--start-group "../../../bin.v2/libs/smart_ptr/test/abi_test_mt_nt.test/gcc-14.3/gentoorelease/x86_64/pch-off/threading-multi/visibility-hidden/abi_test_main.o" "../../../bin.v2/libs/smart_ptr/test/gcc-14.3/gentoorelease/x86_64/link-static/pch-off/threading-multi/visibility-hidden/libabi_test_nt.a" "../../../bin.v2/libs/atomic/build/gcc-14.3/gentoorelease/x86_64/pch-off/threading-multi/visibility-hidden/libboost_atomic.so.1.89.0" "../../../bin.v2/libs/atomic/build/gcc-14.3/gentoorelease/x86_64/link-static/pch-off/threading-multi/visibility-hidden/libboost_atomic.a" -Wl,-Bstatic -Wl,-Bdynamic -lrt -Wl,--end-group -fPIC -m64 -pthread -fvisibility=hidden -fvisibility-inlines-hidden -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0
../../../boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp:70:28: error: type ‘struct sp_counted_base’ violates the C++ One Definition Rule [-Werror=odr]
70 | class BOOST_SYMBOL_VISIBLE sp_counted_base
| ^
../../../boost/smart_ptr/detail/sp_counted_base_nt.hpp:38:28: note: a different type is defined in another translation unit
38 | class BOOST_SYMBOL_VISIBLE sp_counted_base
| ^
../../../boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp:77:27: note: the first difference of corresponding definitions is field ‘use_count_’
77 | boost::uint_least32_t use_count_; // #shared
| ^
../../../boost/smart_ptr/detail/sp_counted_base_nt.hpp:45:26: note: a field of same name but different type is defined in another translation unit
45 | boost::int_least32_t use_count_; // #shared
| ^
../../../boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp:70:28: note: type ‘uint_least32_t’ should match type ‘int_least32_t’
70 | class BOOST_SYMBOL_VISIBLE sp_counted_base
| ^
../../../boost/smart_ptr/detail/sp_counted_base_nt.hpp:86:10: error: type of ‘release’ does not match original declaration [-Werror=lto-type-mismatch]
86 | void release() noexcept
| ^
../../../boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp:116:10: note: ‘release’ was previously declared here
116 | void release() // nothrow
| ^
../../../boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp:116:10: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
../../../boost/smart_ptr/detail/sp_counted_base_nt.hpp:100:10: error: type of ‘weak_release’ does not match original declaration [-Werror=lto-type-mismatch]
100 | void weak_release() noexcept
| ^
../../../boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp:130:10: note: ‘weak_release’ was previously declared here
130 | void weak_release() // nothrow
| ^
../../../boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp:130:10: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
../../../boost/smart_ptr/detail/sp_counted_base_nt.hpp:65:18: error: type of ‘destroy’ does not match original declaration [-Werror=lto-type-mismatch]
65 | virtual void destroy() noexcept // nothrow
| ^
../../../boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp:97:18: note: ‘destroy’ was previously declared here
97 | virtual void destroy() // nothrow
| ^
../../../boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp:97:18: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
lto1: some warnings being treated as errors
lto-wrapper: fatal error: /usr/bin/x86_64-pc-linux-gnu-g++ returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
...skipped <p../../../bin.v2/libs/smart_ptr/test/abi_test_mt_nt.test/gcc-14.3/gentoorelease/x86_64/pch-off/threading-multi/visibility-hidden>abi_test_mt_nt.run for lack of <p../../../bin.v2/libs/smart_ptr/test/abi_test_mt_nt.test/gcc-14.3/gentoorelease/x86_64/pch-off/threading-multi/visibility-hidden>abi_test_mt_nt...
common.mkdir ../../../bin.v2/libs/smart_ptr/test/get_deleter_test2_no_rtti.test
mkdir -p "../../../bin.v2/libs/smart_ptr/test/get_deleter_test2_no_rtti.test"
gcc.link ../../../bin.v2/libs/smart_ptr/test/abi_test_nt_mt.test/gcc-14.3/gentoorelease/x86_64/pch-off/threading-multi/visibility-hidden/abi_test_nt_mt
"x86_64-pc-linux-gnu-g++" -Wl,-rpath -Wl,"/var/tmp/portage/dev-libs/boost-1.89.0/work/boost_1_89_0-abi_x86_64.amd64/bin.v2/libs/atomic/build/gcc-14.3/gentoorelease/x86_64/pch-off/threading-multi/visibility-hidden" -Wl,-rpath-link -Wl,"/var/tmp/portage/dev-libs/boost-1.89.0/work/boost_1_89_0-abi_x86_64.amd64/bin.v2/libs/atomic/build/gcc-14.3/gentoorelease/x86_64/pch-off/threading-multi/visibility-hidden" -o "../../../bin.v2/libs/smart_ptr/test/abi_test_nt_mt.test/gcc-14.3/gentoorelease/x86_64/pch-off/threading-multi/visibility-hidden/abi_test_nt_mt" -Wl,--start-group "../../../bin.v2/libs/smart_ptr/test/abi_test_nt_mt.test/gcc-14.3/gentoorelease/x86_64/pch-off/threading-multi/visibility-hidden/abi_test_main.o" "../../../bin.v2/libs/smart_ptr/test/gcc-14.3/gentoorelease/x86_64/link-static/pch-off/threading-multi/visibility-hidden/libabi_test_mt.a" "../../../bin.v2/libs/atomic/build/gcc-14.3/gentoorelease/x86_64/pch-off/threading-multi/visibility-hidden/libboost_atomic.so.1.89.0" "../../../bin.v2/libs/atomic/build/gcc-14.3/gentoorelease/x86_64/link-static/pch-off/threading-multi/visibility-hidden/libboost_atomic.a" -Wl,-Bstatic -Wl,-Bdynamic -lrt -Wl,--end-group -fPIC -m64 -pthread -fvisibility=hidden -fvisibility-inlines-hidden -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0
../../../boost/smart_ptr/detail/sp_counted_base_nt.hpp:38:28: error: type ‘struct sp_counted_base’ violates the C++ One Definition Rule [-Werror=odr]
38 | class BOOST_SYMBOL_VISIBLE sp_counted_base
| ^
../../../boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp:70:28: note: a different type is defined in another translation unit
70 | class BOOST_SYMBOL_VISIBLE sp_counted_base
| ^
../../../boost/smart_ptr/detail/sp_counted_base_nt.hpp:45:26: note: the first difference of corresponding definitions is field ‘use_count_’
45 | boost::int_least32_t use_count_; // #shared
| ^
../../../boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp:77:27: note: a field of same name but different type is defined in another translation unit
77 | boost::uint_least32_t use_count_; // #shared
| ^
../../../boost/smart_ptr/detail/sp_counted_base_nt.hpp:38:28: note: type ‘int_least32_t’ should match type ‘uint_least32_t’
38 | class BOOST_SYMBOL_VISIBLE sp_counted_base
| ^
../../../boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp:116:10: error: type of ‘release’ does not match original declaration [-Werror=lto-type-mismatch]
116 | void release() // nothrow
| ^
../../../boost/smart_ptr/detail/sp_counted_base_nt.hpp:86:10: note: ‘release’ was previously declared here
86 | void release() noexcept
| ^
../../../boost/smart_ptr/detail/sp_counted_base_nt.hpp:86:10: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
../../../boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp:130:10: error: type of ‘weak_release’ does not match original declaration [-Werror=lto-type-mismatch]
130 | void weak_release() // nothrow
| ^
../../../boost/smart_ptr/detail/sp_counted_base_nt.hpp:100:10: note: ‘weak_release’ was previously declared here
100 | void weak_release() noexcept
| ^
../../../boost/smart_ptr/detail/sp_counted_base_nt.hpp:100:10: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
../../../boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp:97:18: error: type of ‘destroy’ does not match original declaration [-Werror=lto-type-mismatch]
97 | virtual void destroy() // nothrow
| ^
../../../boost/smart_ptr/detail/sp_counted_base_nt.hpp:65:18: note: ‘destroy’ was previously declared here
65 | virtual void destroy() noexcept // nothrow
| ^
../../../boost/smart_ptr/detail/sp_counted_base_nt.hpp:65:18: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
lto1: some warnings being treated as errors
lto-wrapper: fatal error: /usr/bin/x86_64-pc-linux-gnu-g++ returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
...skipped <p../../../bin.v2/libs/smart_ptr/test/abi_test_nt_mt.test/gcc-14.3/gentoorelease/x86_64/pch-off/threading-multi/visibility-hidden>abi_test_nt_mt.run for lack of <p../../../bin.v2/libs/smart_ptr/test/abi_test_nt_mt.test/gcc-14.3/gentoorelease/x86_64/pch-off/threading-multi/visibility-hidden>abi_test_nt_mt...
common.mkdir ../../../bin.v2/libs/smart_ptr/test/get_deleter_test2_no_rtti.test/gcc-14.3
mkdir -p "../../../bin.v2/libs/smart_ptr/test/get_deleter_test2_no_rtti.test/gcc-14.3"
Originally reported downstream: https://bugs.gentoo.org/956660
Full build log: build.log
- Ngôn ngữ chính
- C++
- Star
- 111
- Fork
- 116
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của boostorg/smart_ptr
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
clang-cl 9.0.1 build failuresĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
Tất cả issue của boostorg/smart_ptr
Issue tương tự
-
A-tools P-medium S-ready-to-start studio task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Status: Needs confirmation Status: Needs triage Type: Code Quality
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Image.resolveAssetSource's TypeScript declaration drops the null it returns for an unknown assetĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
react/react-native#59648 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
platform: Linux
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
keepassxreboot/keepassxc#13947 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Shell: serve the home app's Cookie Policy on a hard reloadCó thể đã có người làm @2001anshkaushik đã nhận hôm nay. Đang mởfeature module:ai
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
rocketride-org/rocketride-server#2899 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày