Skip to content

Conversation

@mattip
Copy link
Contributor

@mattip mattip commented Dec 22, 2025

Towards #5560

  • Add a OPENBLAS_EXPORT macro that maps to __attribute__ ((visibility ("default")))
  • Add the macro to all the exported functions: everything in interfaces and some in kernels/generic
  • Add a directive to the PROLOGUE assembler macro to hide functions by default, and use a PROLOGUE_EXPORT macro where functions should be exported

Where would be the best place to add a non-MSVC default -fvisibility=hidden? Somewhere in Makefile.system I guess, but how/where?

Note most of this was done as part of MacPython/openblas-libs#241, and I tested it there on the most popular builds.

.SUFFIXES: .c .o
.c.o:
$(CC) $(CFLAGS) -I../include -c -o $@ $<
$(CC) $(filter-out -fvisibility=hidden, $(CFLAGS)) -I../include -c -o $@ $<
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than add OPENBLAS_EXPORT to all the functions here and in ../utils, I removed the flag from the Makefile. I should do the same for the CMake. How does one tweak the flags per-directory in CMake?

@mattip
Copy link
Contributor Author

mattip commented Dec 22, 2025

The clang builds are complaining about the assembler directive .hidden

  ../kernel/x86_64/qconjg.S:42:35: error: unknown directive
 .text;.align 5; .globl _qconjg_; .hidden _qconjg_; _qconjg_:
                                  ^

But the passing gcc builds are happy enough with it. I wonder if there is another way to tell clang to hide the assembler function without resorting to objcopy

@mattip
Copy link
Contributor Author

mattip commented Dec 22, 2025

I got the documentation for .hidden here which mentions ELF. So I will put it behind #ifdef __ELF__

@mattip
Copy link
Contributor Author

mattip commented Dec 23, 2025

The Windows_cl job is failing since on windows I need the full dllexport, dllimport dance in cblas.h. It is used both internally during compilation (hence dllimport) and externally shipped (hence dllexport).

The other failures are due to timeouts or network issues, and I don't think they are connected to this PR.

I am still thinking about the best way to add -fvisibility=hidden to CFLAGS, any hints are welcome.

@mattip
Copy link
Contributor Author

mattip commented Dec 23, 2025

Ahh, the shipped cblas.h is actually heavily modified in the build process (in both CMakeLists.txt and Makefile.install, look for "Generating cblas.h"), so I could add the OPENBLAS_EXPORT for the build and remove it in the generated file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant