diff options
Diffstat (limited to 'config.tests/static_link_order')
-rw-r--r-- | config.tests/static_link_order/CMakeLists.txt | 25 | ||||
-rw-r--r-- | config.tests/static_link_order/main.cpp | 8 | ||||
-rw-r--r-- | config.tests/static_link_order/objlib.cpp | 8 | ||||
-rw-r--r-- | config.tests/static_link_order/staticlib1.cpp | 8 | ||||
-rw-r--r-- | config.tests/static_link_order/staticlib2.cpp | 5 |
5 files changed, 54 insertions, 0 deletions
diff --git a/config.tests/static_link_order/CMakeLists.txt b/config.tests/static_link_order/CMakeLists.txt new file mode 100644 index 0000000000..c174fb95db --- /dev/null +++ b/config.tests/static_link_order/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +# The test represents the order-related issue that we have with the ld linker. +# +# CMake versions < 3.21.0 produce the following linker line: +# <binary_name> main.cpp -o static_link_order_test libstaticLib.a objlib.cpp.o +# Since 'static_link_order_test' doesn't have direct use of 'staticlib2.cpp.o' symbols +# the translation unit is not linked. When we link objlib.cpp.o it cannot resolve symbols from +# staticlib2.cpp.o. +# +# For now it's only applicable for ld-like linkers. 'lld' has no such issue. +cmake_minimum_required(VERSION 3.16) + +project(static_link_order_test LANGUAGES CXX) + +add_library(objLib OBJECT objlib.cpp) +add_library(staticLib STATIC staticlib1.cpp staticlib2.cpp) + +target_link_libraries(staticLib + INTERFACE objLib "$<TARGET_OBJECTS:objLib>" +) + +add_executable(static_link_order_test main.cpp) +target_link_libraries(static_link_order_test PRIVATE staticLib) diff --git a/config.tests/static_link_order/main.cpp b/config.tests/static_link_order/main.cpp new file mode 100644 index 0000000000..93b8825fd9 --- /dev/null +++ b/config.tests/static_link_order/main.cpp @@ -0,0 +1,8 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: BSD-3-Clause + +void staticLibFunc1(); + +int main() { + staticLibFunc1(); +} diff --git a/config.tests/static_link_order/objlib.cpp b/config.tests/static_link_order/objlib.cpp new file mode 100644 index 0000000000..0ad7b76a80 --- /dev/null +++ b/config.tests/static_link_order/objlib.cpp @@ -0,0 +1,8 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: BSD-3-Clause + +void staticLibFunc2(); + +void objLibFunc() { + staticLibFunc2(); +} diff --git a/config.tests/static_link_order/staticlib1.cpp b/config.tests/static_link_order/staticlib1.cpp new file mode 100644 index 0000000000..f120f9229b --- /dev/null +++ b/config.tests/static_link_order/staticlib1.cpp @@ -0,0 +1,8 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: BSD-3-Clause + +void objLibFunc(); + +void staticLibFunc1() { + objLibFunc(); +} diff --git a/config.tests/static_link_order/staticlib2.cpp b/config.tests/static_link_order/staticlib2.cpp new file mode 100644 index 0000000000..a9abf424fe --- /dev/null +++ b/config.tests/static_link_order/staticlib2.cpp @@ -0,0 +1,5 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: BSD-3-Clause + +void staticLibFunc2() { +} |