Skip to content

Commit 789197e

Browse files
committed
cblas: mark cblas_xerbla and F77_xerbla symbols as weak
1 parent 1827da0 commit 789197e

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
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
{

0 commit comments

Comments
 (0)