Skip to content

Commit 8ebb2ad

Browse files
authored
Merge pull request #521 from veprbl/pr/cblas_use_weak_symbols
cblas: mark cblas_xerbla and F77_xerbla symbols as weak
2 parents 2e71a4f + b4123cb commit 8ebb2ad

File tree

13 files changed

+36
-4
lines changed

13 files changed

+36
-4
lines changed

CBLAS/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ if(NOT FortranCInterface_GLOBAL_FOUND OR NOT FortranCInterface_MODULE_FOUND)
1818
${LAPACK_BINARY_DIR}/include/cblas_mangling.h)
1919
endif()
2020

21+
include(CheckCSourceCompiles)
22+
check_c_source_compiles("void __attribute__((weak)) main() {};"
23+
HAS_ATTRIBUTE_WEAK_SUPPORT)
24+
2125
include_directories(include ${LAPACK_BINARY_DIR}/include)
2226
add_subdirectory(include)
2327
add_subdirectory(src)

CBLAS/src/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ set_target_properties(
120120
VERSION ${LAPACK_VERSION}
121121
SOVERSION ${LAPACK_MAJOR_VERSION}
122122
)
123+
if(HAS_ATTRIBUTE_WEAK_SUPPORT)
124+
target_compile_definitions(${CBLASLIB} PRIVATE HAS_ATTRIBUTE_WEAK_SUPPORT)
125+
endif()
123126
target_include_directories(${CBLASLIB} PUBLIC
124127
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
125128
$<INSTALL_INTERFACE:include>

CBLAS/src/cblas_xerbla.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
#include "cblas.h"
66
#include "cblas_f77.h"
77

8-
void cblas_xerbla(CBLAS_INDEX info, const char *rout, const char *form, ...)
8+
void
9+
#ifdef HAS_ATTRIBUTE_WEAK_SUPPORT
10+
__attribute__((weak))
11+
#endif
12+
cblas_xerbla(CBLAS_INDEX info, const char *rout, const char *form, ...)
913
{
1014
extern int RowMajorStrg;
1115
char empty[1] = "";

CBLAS/src/xerbla.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66
#define XerblaStrLen 6
77
#define XerblaStrLen1 7
88

9+
void
10+
#ifdef HAS_ATTRIBUTE_WEAK_SUPPORT
11+
__attribute__((weak))
12+
#endif
13+
F77_xerbla
914
#ifdef F77_CHAR
10-
void F77_xerbla(F77_CHAR F77_srname, void *vinfo)
15+
(F77_CHAR F77_srname, void *vinfo)
1116
#else
12-
void F77_xerbla(char *srname, void *vinfo)
17+
(char *srname, void *vinfo)
1318
#endif
1419

1520
{

CBLAS/testing/c_c2chke.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ void F77_c2chke(char *rout) {
3636
extern int RowMajorStrg;
3737
extern char *cblas_rout;
3838

39+
#ifndef HAS_ATTRIBUTE_WEAK_SUPPORT
3940
if (link_xerbla) /* call these first to link */
4041
{
4142
cblas_xerbla(cblas_info,cblas_rout,"");
4243
F77_xerbla(cblas_rout,&cblas_info);
4344
}
45+
#endif
4446

4547
cblas_ok = TRUE ;
4648
cblas_lerr = PASSED ;

CBLAS/testing/c_c3chke.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ void F77_c3chke(char * rout) {
3939
cblas_ok = TRUE ;
4040
cblas_lerr = PASSED ;
4141

42+
#ifndef HAS_ATTRIBUTE_WEAK_SUPPORT
4243
if (link_xerbla) /* call these first to link */
4344
{
4445
cblas_xerbla(cblas_info,cblas_rout,"");
4546
F77_xerbla(cblas_rout,&cblas_info);
4647
}
48+
#endif
4749

4850
if (strncmp( sf,"cblas_cgemm" ,11)==0) {
4951
cblas_rout = "cblas_cgemm" ;

CBLAS/testing/c_d2chke.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ void F77_d2chke(char *rout) {
3434
extern int RowMajorStrg;
3535
extern char *cblas_rout;
3636

37+
#ifndef HAS_ATTRIBUTE_WEAK_SUPPORT
3738
if (link_xerbla) /* call these first to link */
3839
{
3940
cblas_xerbla(cblas_info,cblas_rout,"");
4041
F77_xerbla(cblas_rout,&cblas_info);
4142
}
43+
#endif
4244

4345
cblas_ok = TRUE ;
4446
cblas_lerr = PASSED ;

CBLAS/testing/c_d3chke.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ void F77_d3chke(char *rout) {
3434
extern int RowMajorStrg;
3535
extern char *cblas_rout;
3636

37+
#ifndef HAS_ATTRIBUTE_WEAK_SUPPORT
3738
if (link_xerbla) /* call these first to link */
3839
{
3940
cblas_xerbla(cblas_info,cblas_rout,"");
4041
F77_xerbla(cblas_rout,&cblas_info);
4142
}
43+
#endif
4244

4345
cblas_ok = TRUE ;
4446
cblas_lerr = PASSED ;

CBLAS/testing/c_s2chke.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ void F77_s2chke(char *rout) {
3434
extern int RowMajorStrg;
3535
extern char *cblas_rout;
3636

37+
#ifndef HAS_ATTRIBUTE_WEAK_SUPPORT
3738
if (link_xerbla) /* call these first to link */
3839
{
3940
cblas_xerbla(cblas_info,cblas_rout,"");
4041
F77_xerbla(cblas_rout,&cblas_info);
4142
}
43+
#endif
4244

4345
cblas_ok = TRUE ;
4446
cblas_lerr = PASSED ;

CBLAS/testing/c_s3chke.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ void F77_s3chke(char *rout) {
3434
extern int RowMajorStrg;
3535
extern char *cblas_rout;
3636

37+
#ifndef HAS_ATTRIBUTE_WEAK_SUPPORT
3738
if (link_xerbla) /* call these first to link */
3839
{
3940
cblas_xerbla(cblas_info,cblas_rout,"");
4041
F77_xerbla(cblas_rout,&cblas_info);
4142
}
43+
#endif
4244

4345
cblas_ok = TRUE ;
4446
cblas_lerr = PASSED ;

0 commit comments

Comments
 (0)