[OpenMP][cmake] Simplify -m32 handling (#142742)
Linking `libomp.so` on 32-bit SPARC `FAIL`s with ``` ld: fatal: file projects/openmp/runtime/src/CMakeFiles/omp.dir/z_Linux_asm.S.o: wrong ELF class: ELFCLASS64 ``` This was a 1-stage build with a 64-bit-default `gcc`. Unlike the C++ sources, which were compiled as 32-bit objects due to the use of `-DCMAKE_CXX_FLAGS=-m32`, the assembler sources were not. This patch simplifies passing `-m32`: instead of doing it per architecture, `-m32` is now always passed when the target uses 32-bit pointers and supports the option. Tested on `sparc-sun-solaris2.11`, `sparcv9-sun-solaris2.11`, `sparc-unknown-linux-gnu`, `sparc64-unknown-linux-gnu`, `i386-pc-solaris2.11`, `amd64-pc-solaris2.11`, `i686-pc-linux-gnu`, and `x86_64-pc-linux-gnu`.
This commit is contained in:
@@ -60,10 +60,10 @@ function(libomp_get_cxxflags cxxflags)
|
||||
libomp_append(flags_local -Qinline-min-size=1 LIBOMP_HAVE_INLINE_MIN_SIZE_FLAG)
|
||||
endif()
|
||||
# Architectural C and C++ flags
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
libomp_append(flags_local -m32 LIBOMP_HAVE_M32_FLAG)
|
||||
endif()
|
||||
if(${IA32})
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
libomp_append(flags_local -m32 LIBOMP_HAVE_M32_FLAG)
|
||||
endif()
|
||||
libomp_append(flags_local /arch:SSE2 LIBOMP_HAVE_ARCH_SSE2_FLAG)
|
||||
libomp_append(flags_local -msse2 LIBOMP_HAVE_MSSE2_FLAG)
|
||||
libomp_append(flags_local -falign-stack=maintain-16-byte LIBOMP_HAVE_FALIGN_STACK_FLAG)
|
||||
@@ -81,10 +81,10 @@ endfunction()
|
||||
function(libomp_get_asmflags asmflags)
|
||||
set(asmflags_local)
|
||||
# Architectural assembler flags
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
libomp_append(asmflags_local -m32 LIBOMP_HAVE_M32_FLAG)
|
||||
endif()
|
||||
if(${IA32})
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
libomp_append(asmflags_local -m32 LIBOMP_HAVE_M32_FLAG)
|
||||
endif()
|
||||
libomp_append(asmflags_local /safeseh LIBOMP_HAVE_SAFESEH_MASM_FLAG)
|
||||
libomp_append(asmflags_local /coff LIBOMP_HAVE_COFF_MASM_FLAG)
|
||||
elseif(${MIC})
|
||||
@@ -112,10 +112,10 @@ function(libomp_get_ldflags ldflags)
|
||||
libomp_append(ldflags_local -static-intel LIBOMP_HAVE_STATIC_INTEL_FLAG)
|
||||
libomp_append(ldflags_local /SAFESEH LIBOMP_HAVE_SAFESEH_FLAG)
|
||||
# Architectural linker flags
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
libomp_append(ldflags_local -m32 LIBOMP_HAVE_M32_FLAG)
|
||||
endif()
|
||||
if(${IA32})
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
libomp_append(ldflags_local -m32 LIBOMP_HAVE_M32_FLAG)
|
||||
endif()
|
||||
libomp_append(ldflags_local -msse2 LIBOMP_HAVE_MSSE2_FLAG)
|
||||
elseif(${MIC})
|
||||
libomp_append(ldflags_local -mmic LIBOMP_HAVE_MMIC_FLAG)
|
||||
@@ -159,7 +159,7 @@ endfunction()
|
||||
# Fortran flags
|
||||
function(libomp_get_fflags fflags)
|
||||
set(fflags_local)
|
||||
if(${IA32})
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
libomp_append(fflags_local -m32 LIBOMP_HAVE_M32_FORTRAN_FLAG)
|
||||
endif()
|
||||
set(fflags_local ${fflags_local} ${LIBOMP_FFLAGS})
|
||||
|
||||
Reference in New Issue
Block a user