From 2221b25dac767ad2d3988af37e711c12e1ac9d78 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 18 Jul 2022 11:01:18 -0700 Subject: [PATCH] CMake: add one more test for no_direct_extern_access Found while compiling qtdeclarative tests: FAILED: qtdeclarative/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen [...] ld: qtdeclarative/tests/auto/qml/qmlcppcodegen/data/TestTypes/libcodegen_test_moduleplugin.a(codegen_test_moduleplugin_TestTypesPlugin.cpp.o): non-canonical reference to canonical protected function `_Z28qml_register_types_TestTypesv' in qtdeclarative/tests/auto/qml/qmlcppcodegen/data/libcodegen_test_module.a(codegen_test_module_qmltyperegistrations.cpp.o) ld: failed to set dynamic section sizes: bad value collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed. See https://sourceware.org/bugzilla/show_bug.cgi?id=29377 Pick-to: 6.4 Change-Id: I3859764fed084846bcb0fffd1702fe6da341a9e3 Reviewed-by: Alexandru Croitor --- config.tests/no_direct_extern_access/CMakeLists.txt | 3 ++- config.tests/no_direct_extern_access/main.cpp | 10 +++++++++- config.tests/no_direct_extern_access/other.cpp | 8 ++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 config.tests/no_direct_extern_access/other.cpp diff --git a/config.tests/no_direct_extern_access/CMakeLists.txt b/config.tests/no_direct_extern_access/CMakeLists.txt index 7c823487518..b4b881f1dc7 100644 --- a/config.tests/no_direct_extern_access/CMakeLists.txt +++ b/config.tests/no_direct_extern_access/CMakeLists.txt @@ -2,9 +2,10 @@ cmake_minimum_required(VERSION 3.16) project(direct_extern_access LANGUAGES CXX) # this is the test found in https://sourceware.org/bugzilla/show_bug.cgi?id=29087 +# and https://sourceware.org/bugzilla/show_bug.cgi?id=29377 add_library(no_extern_access_lib SHARED lib.cpp) -add_executable(no_extern_access_main main.cpp) +add_executable(no_extern_access_main other.cpp main.cpp) target_compile_options(no_extern_access_lib PRIVATE "-Werror") target_compile_options(no_extern_access_lib PUBLIC "$<$:-mno-direct-extern-access>") diff --git a/config.tests/no_direct_extern_access/main.cpp b/config.tests/no_direct_extern_access/main.cpp index 9cf0323766a..541c8b4b334 100644 --- a/config.tests/no_direct_extern_access/main.cpp +++ b/config.tests/no_direct_extern_access/main.cpp @@ -1,10 +1,18 @@ // Copyright (C) 2022 Intel Corporation. // SPDX-License-Identifier: MIT -// This is the test found in https://sourceware.org/bugzilla/show_bug.cgi?id=29087 +// This is combining the tests found in: +// https://sourceware.org/bugzilla/show_bug.cgi?id=29087 +// https://sourceware.org/bugzilla/show_bug.cgi?id=29377 #include "lib.h" +extern void foo(); // other.cpp +void (*get_foo())() +{ + return foo; +} + struct Local : S { }; int main() { diff --git a/config.tests/no_direct_extern_access/other.cpp b/config.tests/no_direct_extern_access/other.cpp new file mode 100644 index 00000000000..ff12b109300 --- /dev/null +++ b/config.tests/no_direct_extern_access/other.cpp @@ -0,0 +1,8 @@ +// Copyright (C) 2022 Intel Corporation. +// SPDX-License-Identifier: MIT + +// This is the test found in https://sourceware.org/bugzilla/show_bug.cgi?id=29377 + +__attribute__((visibility("protected"))) void foo() +{ +}