This is an archive of the discontinued LLVM Phabricator instance.

[libcxx][test] Test visibility option before using it
AbandonedPublic

Authored by jsji on Feb 18 2022, 1:28 PM.

Details

Reviewers
daltenty
Quuxplusone
ldionne
Mordante
sfertile
Group Reviewers
Restricted Project
Restricted Project
Summary

On some platform visibility option might be unsupported. eg: AIX.
The error 'unsupported option '-fvisibility=hidden'' will prevent us
from running the intended test.

This patch propose that we set the substition according to compiler
support.

Diff Detail

Event Timeline

jsji created this revision.Feb 18 2022, 1:28 PM
jsji requested review of this revision.Feb 18 2022, 1:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 18 2022, 1:28 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
jsji added a comment.Feb 28 2022, 7:48 AM

gentle ping...

ldionne requested changes to this revision.Mar 4 2022, 11:24 AM
ldionne added inline comments.
libcxx/test/libcxx/debug/extern-templates.sh.cpp
22

I checked and this test basically passes vacuously when we don't enforce hidden visibility. So instead, I would either mark the test as truly failing on AIX for lack of being able to control visibility (if that's the case -- IDK how AIX works when it comes to visibility):

// AIX doesn't have a notion of visibility, so this test is vacuous.
// UNSUPPORTED: whatever-triple-you-use-for-aix

Or, if there *is* a notion of visibility and it's simply that the compiler doesn't support -fvisibility=hidden, we should:

  1. File a bug for the compiler to start supporting the option, and
  1. Use this diff instead:
diff --git a/libcxx/test/libcxx/debug/extern-templates.sh.cpp b/libcxx/test/libcxx/debug/extern-templates.sh.cpp
index b43f4d10af5c..c635674a6606 100644
--- a/libcxx/test/libcxx/debug/extern-templates.sh.cpp
+++ b/libcxx/test/libcxx/debug/extern-templates.sh.cpp
@@ -21,12 +21,12 @@
 // option which clang doesn't accept on Windows.)
 // UNSUPPORTED: windows
 
-// XFAIL: LIBCXX-AIX-FIXME
-
-// RUN: %{cxx} %{flags} %{compile_flags} %s %{link_flags} -fPIC -DTU1 -D_LIBCPP_DEBUG=1 -fvisibility=hidden -shared -o %t.lib
-// RUN: cd %T && %{cxx} %{flags} %{compile_flags} %s ./%basename_t.tmp.lib %{link_flags} -DTU2 -D_LIBCPP_DEBUG=1 -fvisibility=hidden -o %t.exe
+// RUN: %{cxx} %{flags} %{compile_flags} %s %{link_flags} -fPIC -DTU1 -D_LIBCPP_DEBUG=1 -shared -o %t.lib
+// RUN: cd %T && %{cxx} %{flags} %{compile_flags} %s ./%basename_t.tmp.lib %{link_flags} -DTU2 -D_LIBCPP_DEBUG=1 -o %t.exe
 // RUN: %{exec} %t.exe
 
+#pragma GCC visibility push(hidden)
+
 #include <cassert>
 #include <cstdio>
 #include <sstream>
This revision now requires changes to proceed.Mar 4 2022, 11:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 4 2022, 11:24 AM
jsji abandoned this revision.Mar 4 2022, 11:34 AM

Yes, AIX clang hasn't supported visibility yet, we simply ignore all the visibility for now.

OK. Then I think we will leave this test as it is for now, we should be able to re-enable it once we support visibility later.

We could pass the linker an export list with the desired visibility for the functions in test on AIX if we need the visibility for the test. This is likely what we'll have to do in other places in libc++ until clang on AIX has real visibility support.