File tree Expand file tree Collapse file tree 4 files changed +56
-1
lines changed Expand file tree Collapse file tree 4 files changed +56
-1
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,11 @@ set(CPACK_PACKAGE_VERSION_PATCH "0")
19
19
set (CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR} /README.md" )
20
20
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR} /LICENSE" )
21
21
22
+ if (NOT WIN32 )
23
+ set (GLIBC_WRAP_FUNCTIONS
24
+ -Wl,--wrap=gettid
25
+ -Wl,--wrap=log2 )
26
+ endif ()
22
27
# Enforce keeping the source directory clean by building in a separate
23
28
# directory. This avoids unnecessary corner cases, e.g., copying files
24
29
# from source to binary directory with identical relative paths.
@@ -333,7 +338,10 @@ target_link_libraries(acl PRIVATE
333
338
if (UNIX )
334
339
# we need this flag to expose symbols, otherwise linking will fail with:
335
340
# "relocation against protected symbol X can not be used when making a shared object"
341
+ add_subdirectory (glibc_wrap )
336
342
set_target_properties (acl PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic" )
343
+ target_include_directories (acl PRIVATE ${CMAKE_SOURCE_DIR} /glibc_wrap )
344
+ target_link_libraries (acl PRIVATE glibc_wrap )
337
345
endif ()
338
346
339
347
set_property (TARGET acl PROPERTY PUBLIC_HEADER
Original file line number Diff line number Diff line change 36
36
/fpga-runtime-for-opencl/include/CL/opencl.h
37
37
/fpga-runtime-for-opencl/include/CL/opencl.hpp
38
38
/fpga-runtime-for-opencl/include/MMD/aocl_mmd.h
39
- /fpga-runtime-for-opencl/include/MMD/aocl_mmd_deprecated.h
39
+ /fpga-runtime-for-opencl/include/MMD/aocl_mmd_deprecated.h
40
+ /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/glibc_wrap/libglibc_wrap.a
Original file line number Diff line number Diff line change
1
+ if (NOT WIN32 )
2
+ add_library (glibc_wrap STATIC glibc_wrap.c )
3
+ # Ensure position-independent code is generated
4
+ set_target_properties (glibc_wrap PROPERTIES POSITION_INDEPENDENT_CODE ON )
5
+ target_include_directories (glibc_wrap PRIVATE ${CMAKE_SOURCE_DIR} /src )
6
+ # Specify the wrapped functions on the interface link options.
7
+ # This causes libraries linking against this one to use the wrapped
8
+ # functions rather than those in a potentially too new glibc for
9
+ # our minimum supported OS. See glibc_wrap.c for details.
10
+ target_link_libraries (glibc_wrap INTERFACE ${GLIBC_WRAP_FUNCTIONS} )
11
+
12
+ # Link the math library for debian-11-arm-dev
13
+ target_link_libraries (glibc_wrap INTERFACE m )
14
+
15
+ install (TARGETS glibc_wrap DESTINATION ${CMAKE_SOURCE_DIR} /glibc_wrap )
16
+ endif ()
Original file line number Diff line number Diff line change
1
+ // These functions are only called by our code when built on newer distros. We
2
+ // add '-Wl,--wrap={funcname}' to the link line which changes all calls to
3
+ // '{funcname}' to '__wrap_{funcname}'
4
+
5
+ // For all the gritty details:
6
+ // https://www.win.tue.nl/~aeb/linux/misc/gcc-semibug.html
7
+ // https://stackoverflow.com/questions/4032373/linking-against-an-old-version-of-libc-to-provide-greater-application-coverage
8
+
9
+ #include <linux/unistd.h>
10
+ #include <math.h>
11
+ #include <sys/syscall.h>
12
+ #include <unistd.h>
13
+
14
+ #ifndef __arm__
15
+ // Use GLIBC 2.2.5 versioning only if not on ARM
16
+ asm(".symver log2_glibc_225, log2@GLIBC_2.2.5" );
17
+ extern double log2_glibc_225 (double num );
18
+ #endif
19
+
20
+ double __wrap_log2 (double num ) {
21
+ #ifdef __arm__
22
+ // If compiling for ARM, just call the system-native log2 function
23
+ return log2 (num );
24
+ #else
25
+ // Call the GLIBC 2.2.5 version of log2 if not on ARM
26
+ return log2_glibc_225 (num );
27
+ #endif
28
+ }
29
+
30
+ pid_t __wrap_gettid (void ) { return (pid_t )syscall (SYS_gettid ); }
You can’t perform that action at this time.
0 commit comments