Skip to content

Commit fc645ff

Browse files
authored
Merge pull request #52 from jgunthorpe/arch-fix
Support compiling on architectures without cache coherent DMA
2 parents c01be00 + 6b26a9e commit fc645ff

File tree

21 files changed

+485
-101
lines changed

21 files changed

+485
-101
lines changed

CMakeLists.txt

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ CHECK_C_SOURCE_COMPILES("
203203
HAVE_FUNC_ATTRIBUTE_ALWAYS_INLINE
204204
FAIL_REGEX "warning")
205205

206+
# Provide a shim if C11 stdatomic.h is not supported.
207+
CHECK_INCLUDE_FILE("stdatomic.h" HAVE_STDATOMIC)
208+
RDMA_DoFixup("${HAVE_STDATOMIC}" "stdatomic.h")
209+
206210
# Enable development support features
207211
# Prune unneeded shared libraries during linking
208212
RDMA_AddOptLDFlag(CMAKE_EXE_LINKER_FLAGS SUPPORTS_AS_NEEDED "-Wl,--as-needed")
@@ -278,6 +282,14 @@ check_type_size("long" SIZEOF_LONG BUILTIN_TYPES_ONLY LANGUAGE C)
278282

279283
include(RDMA_LinuxHeaders)
280284

285+
# Determine if this arch supports cache coherent DMA. This isn't really an
286+
# arch specific property, but for our purposes arches that do not support it
287+
# also do not define wmb/etc which breaks our compile.
288+
CHECK_C_SOURCE_COMPILES("
289+
#include \"${CMAKE_CURRENT_SOURCE_DIR}/libibverbs/arch.h\"
290+
int main(int argc,const char *argv[]) {return 0;}"
291+
HAVE_COHERENT_DMA)
292+
281293
#-------------------------
282294
# Apply fixups
283295

@@ -358,18 +370,21 @@ add_subdirectory(librdmacm/man)
358370
add_subdirectory(libibcm)
359371

360372
# Providers
373+
if (HAVE_COHERENT_DMA)
361374
add_subdirectory(providers/cxgb3)
362375
add_subdirectory(providers/cxgb4)
363-
add_subdirectory(providers/hfi1verbs)
364376
add_subdirectory(providers/hns)
365377
add_subdirectory(providers/i40iw)
366-
add_subdirectory(providers/ipathverbs)
367378
add_subdirectory(providers/mlx4)
368379
add_subdirectory(providers/mlx5)
369380
add_subdirectory(providers/mthca)
370381
add_subdirectory(providers/nes)
371382
add_subdirectory(providers/ocrdma)
372383
add_subdirectory(providers/qedr)
384+
endif()
385+
386+
add_subdirectory(providers/hfi1verbs)
387+
add_subdirectory(providers/ipathverbs)
373388
add_subdirectory(providers/rxe)
374389
add_subdirectory(providers/rxe/man)
375390

@@ -396,6 +411,12 @@ message(STATUS "Missing Optional Items:")
396411
if (NOT HAVE_FUNC_ATTRIBUTE_ALWAYS_INLINE)
397412
message(STATUS " Compiler attribute always_inline NOT supported")
398413
endif()
414+
if (NOT HAVE_COHERENT_DMA)
415+
message(STATUS " Architecture NOT able to do coherent DMA (check libibverbs/arch.h) some providers disabled!")
416+
endif()
417+
if (NOT HAVE_STDATOMIC)
418+
message(STATUS " C11 stdatomic.h NOT available (old compiler)")
419+
endif()
399420
if (NOT HAVE_VALGRIND_MEMCHECK)
400421
message(STATUS " Valgrind memcheck.h NOT enabled")
401422
endif()

buildlib/RDMA_EnableCStd.cmake

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,17 @@ function(RDMA_AddOptCFlag TO_VAR CACHE_VAR FLAG)
3333
endif()
3434
endfunction()
3535

36-
# Enable the minimum required gnu99 standard in the compiler.
36+
# Enable the minimum required gnu11 standard in the compiler
37+
# This was introduced in GCC 4.7
3738
function(RDMA_EnableCStd)
3839
if (CMAKE_VERSION VERSION_LESS "3.1")
3940
# Check for support of the usual flag
40-
CHECK_C_COMPILER_FLAG("-std=gnu99" SUPPORTS_GNU99)
41-
if (SUPPORTS_GNU99)
42-
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99" PARENT_SCOPE)
41+
CHECK_C_COMPILER_FLAG("-std=gnu11" SUPPORTS_GNU11)
42+
if (SUPPORTS_GNU11)
43+
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11" PARENT_SCOPE)
4344
endif()
4445
else()
4546
# Newer cmake can do this internally
46-
set(CMAKE_C_STANDARD 99 PARENT_SCOPE)
47+
set(CMAKE_C_STANDARD 11 PARENT_SCOPE)
4748
endif()
4849
endfunction()

0 commit comments

Comments
 (0)