Skip to content

Commit 9b64d2f

Browse files
committed
add visibility=default to exported functions, visibility=hidden to most assembler
1 parent c7b0304 commit 9b64d2f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+327
-16
lines changed

common.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,29 @@ please https://github.com/xianyi/OpenBLAS/issues/246
424424
#define BLAS3_MEM_ALLOC_THRESHOLD 32
425425
#endif
426426

427+
/***
428+
For GCC/Clang, always use -fvisibility=hidden. Then mark exported function
429+
implementations with OPENBLAS_EXPORT. For MSVC, using `__declspec` onces makes
430+
the default atrribute for any function in the entire shared object hidden
431+
(observed behaviour, documentation source needed).
432+
**/
433+
#if defined (_WIN32) || defined (__CYGWIN__)
434+
# if defined (__GNUC__)
435+
/* GCC */
436+
# define OPENBLAS_EXPORT __attribute__ ((dllexport))
437+
# define OPENBLAS_IMPORT __attribute__ ((dllimport))
438+
# else
439+
/* MSVC */
440+
# define OPENBLAS_EXPORT __declspec(dllexport)
441+
# define OPENBLAS_IMPORT __declspec(dllimport)
442+
# endif
443+
#else
444+
/* All other platforms. */
445+
# define OPENBLAS_EXPORT __attribute__ ((visibility ("default")))
446+
# define OPENBLAS_IMPORT
447+
#endif
448+
449+
427450
#ifdef QUAD_PRECISION
428451
#include "common_quad.h"
429452
#endif

common_loongarch64.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,14 @@ static inline int get_cpu_model(char *model_name) {
267267
#if defined(ASSEMBLER) && !defined(NEEDPARAM)
268268

269269
#define PROLOGUE \
270+
.text ;\
271+
.align 5 ;\
272+
.globl REALNAME ;\
273+
.hidden REALNAME ;\
274+
.type REALNAME, @function ;\
275+
REALNAME: ;\
276+
277+
#define PROLOGUE_EXPORT \
270278
.text ;\
271279
.align 5 ;\
272280
.globl REALNAME ;\

common_mips.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ static inline int blas_quickdivide(blasint x, blasint y){
7676
#define PROLOGUE \
7777
.arm ;\
7878
.global REALNAME ;\
79+
.hidden REALNAME ;\
80+
REALNAME:
81+
82+
#define PROLOGUE_EXPORT \
83+
.arm ;\
84+
.global REALNAME ;\
7985
REALNAME:
8086

8187
#define EPILOGUE

common_mips64.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,18 @@ static inline int blas_quickdivide(blasint x, blasint y){
206206
#endif
207207

208208
#define PROLOGUE \
209+
.text ;\
210+
.set ASSEMBLER_ARCH ;\
211+
.align 5 ;\
212+
.globl REALNAME ;\
213+
.hidden REALNAME ;\
214+
.ent REALNAME ;\
215+
.type REALNAME, @function ;\
216+
REALNAME: ;\
217+
.set noreorder ;\
218+
.set nomacro
219+
220+
#define PROLOGUE_EXPORT \
209221
.text ;\
210222
.set ASSEMBLER_ARCH ;\
211223
.align 5 ;\

common_power.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,13 @@ static inline int blas_quickdivide(blasint x, blasint y){
532532
#if defined(OS_LINUX) || defined(OS_FREEBSD)
533533
#ifndef __64BIT__
534534
#define PROLOGUE \
535+
.section .text;\
536+
.align 6;\
537+
.globl REALNAME;\
538+
.hidden REALNAME ;\
539+
.type REALNAME, @function;\
540+
REALNAME:
541+
#define PROLOGUE_EXPORT \
535542
.section .text;\
536543
.align 6;\
537544
.globl REALNAME;\
@@ -541,6 +548,13 @@ static inline int blas_quickdivide(blasint x, blasint y){
541548
#else
542549
#if _CALL_ELF == 2
543550
#define PROLOGUE \
551+
.section .text;\
552+
.align 6;\
553+
.globl REALNAME;\
554+
.hidden REALNAME ;\
555+
.type REALNAME, @function;\
556+
REALNAME:
557+
#define PROLOGUE_EXPORT \
544558
.section .text;\
545559
.align 6;\
546560
.globl REALNAME;\
@@ -549,6 +563,21 @@ static inline int blas_quickdivide(blasint x, blasint y){
549563
#define EPILOGUE .size REALNAME, .-REALNAME
550564
#else
551565
#define PROLOGUE \
566+
.section .text;\
567+
.align 5;\
568+
.globl REALNAME;\
569+
.hidden REALNAME ;\
570+
.section ".opd","aw";\
571+
.align 3;\
572+
REALNAME:;\
573+
.quad .REALNAME, .TOC.@tocbase, 0;\
574+
.previous;\
575+
.size REALNAME, 24;\
576+
.type .REALNAME, @function;\
577+
.globl .REALNAME;\
578+
.hidden .REALNAME ;\
579+
.REALNAME:
580+
#define PROLOGUE_EXPORT \
552581
.section .text;\
553582
.align 5;\
554583
.globl REALNAME;\

common_x86.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ static __inline int blas_quickdivide(unsigned int x, unsigned int y){
297297
#endif
298298

299299
#ifdef OS_DARWIN
300-
#define PROLOGUE .text;.align 5; .globl REALNAME; REALNAME:
300+
#define PROLOGUE .text;.align 5; .globl REALNAME; .hidden REALNAME; REALNAME:
301+
#define PROLOGUE_EXPORT .text;.align 5; .globl REALNAME; REALNAME:
301302
#define EPILOGUE .subsections_via_symbols
302303
#define PROFCODE
303304
#endif
@@ -319,6 +320,14 @@ static __inline int blas_quickdivide(unsigned int x, unsigned int y){
319320

320321
#if defined(OS_WINNT) || defined(OS_CYGWIN_NT) || defined(OS_INTERIX)
321322
#define PROLOGUE \
323+
.text; \
324+
.align 16; \
325+
.globl REALNAME ;\
326+
.hidden REALNAME ;\
327+
.def REALNAME;.scl 2;.type 32;.endef; \
328+
REALNAME:
329+
330+
#define PROLOGUE_EXPORT \
322331
.text; \
323332
.align 16; \
324333
.globl REALNAME ;\
@@ -339,7 +348,16 @@ static __inline int blas_quickdivide(unsigned int x, unsigned int y){
339348
.text; \
340349
.align 16; \
341350
.globl REALNAME ;\
342-
.type REALNAME, @function; \
351+
.hidden REALNAME ;\
352+
.type REALNAME, @function; \
353+
REALNAME: \
354+
_CET_ENDBR
355+
356+
#define PROLOGUE_EXPORT \
357+
.text; \
358+
.align 16; \
359+
.globl REALNAME ;\
360+
.type REALNAME, @function; \
343361
REALNAME: \
344362
_CET_ENDBR
345363

common_x86_64.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ static __inline unsigned int blas_quickdivide(unsigned int x, unsigned int y){
400400
#endif
401401

402402
#ifdef OS_DARWIN
403-
#define PROLOGUE .text;.align 5; .globl REALNAME; REALNAME:
403+
#define PROLOGUE .text;.align 5; .globl REALNAME; .hidden REALNAME; REALNAME:
404+
#define PROLOGUE_EXPORT .text;.align 5; .globl REALNAME; REALNAME:
404405
#define EPILOGUE .subsections_via_symbols
405406
#define PROFCODE
406407
#endif
@@ -441,6 +442,14 @@ static __inline unsigned int blas_quickdivide(unsigned int x, unsigned int y){
441442
.text; \
442443
.align 16; \
443444
.globl REALNAME ;\
445+
.hidden REALNAME ; \
446+
.def REALNAME;.scl 2;.type 32;.endef; \
447+
REALNAME:
448+
449+
#define PROLOGUE_EXPORT \
450+
.text; \
451+
.align 16; \
452+
.globl REALNAME ;\
444453
.def REALNAME;.scl 2;.type 32;.endef; \
445454
REALNAME:
446455

@@ -454,7 +463,16 @@ static __inline unsigned int blas_quickdivide(unsigned int x, unsigned int y){
454463
.text; \
455464
.align 512; \
456465
.globl REALNAME ;\
457-
.type REALNAME, @function; \
466+
.hidden REALNAME ;\
467+
.type REALNAME, @function; \
468+
REALNAME: \
469+
_CET_ENDBR
470+
471+
#define PROLOGUE_EXPORT \
472+
.text; \
473+
.align 512; \
474+
.globl REALNAME ;\
475+
.type REALNAME, @function; \
458476
REALNAME: \
459477
_CET_ENDBR
460478

driver/others/blas_server.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ if (openblas_threads_callback_) {
861861
return 0;
862862
}
863863

864+
OPENBLAS_EXPORT
864865
void goto_set_num_threads(int num_threads) {
865866

866867
long i;
@@ -933,6 +934,7 @@ void goto_set_num_threads(int num_threads) {
933934

934935
}
935936

937+
OPENBLAS_EXPORT
936938
void openblas_set_num_threads(int num_threads) {
937939
goto_set_num_threads(num_threads);
938940

driver/others/memory.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ int blas_get_cpu_number(void){
500500
#endif
501501

502502

503+
OPENBLAS_EXPORT
503504
int openblas_get_num_procs(void) {
504505
#ifndef SMP
505506
return 1;
@@ -508,6 +509,7 @@ int openblas_get_num_procs(void) {
508509
#endif
509510
}
510511

512+
OPENBLAS_EXPORT
511513
int openblas_get_num_threads(void) {
512514
#ifndef SMP
513515
return 1;
@@ -2071,6 +2073,7 @@ int blas_get_cpu_number(void){
20712073
#endif
20722074

20732075

2076+
OPENBLAS_EXPORT
20742077
int openblas_get_num_procs(void) {
20752078
#ifndef SMP
20762079
return 1;
@@ -2079,6 +2082,7 @@ int openblas_get_num_procs(void) {
20792082
#endif
20802083
}
20812084

2085+
OPENBLAS_EXPORT
20822086
int openblas_get_num_threads(void) {
20832087
#ifndef SMP
20842088
return 1;

driver/others/openblas_get_config.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ char *gotoblas_corename(void);
7878
static char tmp_config_str[256];
7979
int openblas_get_parallel(void);
8080

81+
OPENBLAS_EXPORT
8182
char* CNAME(void) {
8283
char tmpstr[20];
8384
strcpy(tmp_config_str, openblas_config_str);
@@ -93,6 +94,7 @@ char tmpstr[20];
9394
}
9495

9596

97+
OPENBLAS_EXPORT
9698
char* openblas_get_corename(void) {
9799
#ifndef DYNAMIC_ARCH
98100
return CHAR_CORENAME;

0 commit comments

Comments
 (0)