forked from qt/qtbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CMake: Test the linker too for -mno-direct-extern-access
The GNU binutils ld linker needed a patch after the tagging of 2.38 to make the new feature work. Before this patch, the linker will fail to link when protected visibility symbols are used in the library, so don't enable the feature unless the linker is recent enough. GNU binutils gold from that version passes this test. LLVM lld is unknown (I didn't test), but LLVM was consulted in developing the feature. Fixes: QTBUG-103493 Change-Id: Ibcde9b9795ad42ac9978fffd16f1c80ca20953ff Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Marc Mutz <[email protected]>
- Loading branch information
1 parent
845491e
commit fdd7227
Showing
5 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
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 | ||
|
||
add_library(no_extern_access_lib SHARED lib.cpp) | ||
add_executable(no_extern_access_main main.cpp) | ||
target_compile_options(no_extern_access_lib PUBLIC "-mno-direct-extern-access") | ||
target_link_libraries(no_extern_access_main no_extern_access_lib) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (C) 2022 Intel Corporation. | ||
// SPDX-License-Identifier: MIT | ||
|
||
// This is the test found in https://sourceware.org/bugzilla/show_bug.cgi?id=29087 | ||
|
||
#define BUILD | ||
#include "lib.h" | ||
|
||
S::~S() { } | ||
void S::f() { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (C) 2022 Intel Corporation. | ||
// SPDX-License-Identifier: MIT | ||
|
||
// This is the test found in https://sourceware.org/bugzilla/show_bug.cgi?id=29087 | ||
|
||
#ifdef BUILD | ||
# define LIB_API __attribute__((visibility("protected"))) | ||
#else | ||
# define LIB_API __attribute__((visibility("default"))) | ||
#endif | ||
|
||
struct LIB_API S | ||
{ | ||
virtual ~S(); | ||
virtual void f(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (C) 2022 Intel Corporation. | ||
// SPDX-License-Identifier: MIT | ||
|
||
// This is the test found in https://sourceware.org/bugzilla/show_bug.cgi?id=29087 | ||
|
||
#include "lib.h" | ||
|
||
struct Local : S { }; | ||
int main() | ||
{ | ||
Local l; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters