Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libigc] Add musl support. #743

Merged
merged 1 commit into from
Apr 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions L/libigc/build_tarballs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,19 @@ cd intel-graphics-compiler-*
install_license LICENSE.md

# Work around compilation failures
sed -i '1 i\#define __STDC_FORMAT_MACROS 1' IGC/AdaptorOCL/Upgrader/llvm9/BitcodeReader.cpp
atomic_patch -p1 ../patches/format_macros.patch
# https://github.com/intel/intel-graphics-compiler/issues/125
atomic_patch -p1 -R ../patches/cbc78036d1a5bd0a889acdc87c2fb902d5ace159.patch
atomic_patch -p1 -R ../patches/static_assert.patch
if [[ "${target}" == *86*-linux-musl* ]]; then
atomic_patch -p1 ../patches/musl-concat.patch
atomic_patch -p1 ../patches/musl-inttypes.patch
# https://github.com/JuliaPackaging/Yggdrasil/issues/739
sed -i '/-fstack-protector/d' IGC/CMakeLists.txt
# https://github.com/JuliaPackaging/BinaryBuilder.jl/issues/387
pushd /opt/${target}/lib/gcc/${target}/*/include
atomic_patch -p0 $WORKSPACE/srcdir/patches/musl-malloc.patch
popd
fi

# the build system uses git
export HOME=$(pwd)
Expand Down Expand Up @@ -94,7 +104,8 @@ make install
# platforms are passed in on the command line
platforms = [
Linux(:i686, libc=:glibc),
Linux(:x86_64, libc=:glibc)
Linux(:x86_64, libc=:glibc),
Linux(:x86_64, libc=:musl),
]
platforms = expand_cxxstring_abis(platforms)

Expand Down
13 changes: 13 additions & 0 deletions L/libigc/bundled/patches/format_macros.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/IGC/AdaptorOCL/Upgrader/llvm9/BitcodeReader.cpp b/IGC/AdaptorOCL/Upgrader/llvm9/BitcodeReader.cpp
index 406fd86c..ebc601f1 100644
--- a/IGC/AdaptorOCL/Upgrader/llvm9/BitcodeReader.cpp
+++ b/IGC/AdaptorOCL/Upgrader/llvm9/BitcodeReader.cpp
@@ -38,6 +38,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#pragma warning(disable:4624)
#pragma warning(disable:4800)

+#define __STDC_FORMAT_MACROS 1
+
#include "common/LLVMWarningsPush.hpp"

#include "llvm/Bitcode/BitcodeReader.h"
43 changes: 43 additions & 0 deletions L/libigc/bundled/patches/musl-concat.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
diff --git a/IGC/AdaptorOCL/OCL/sp/sp_types.h b/IGC/AdaptorOCL/OCL/sp/sp_types.h
index 1fa2d560..3df6b5bd 100644
--- a/IGC/AdaptorOCL/OCL/sp/sp_types.h
+++ b/IGC/AdaptorOCL/OCL/sp/sp_types.h
@@ -46,7 +46,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
typedef unsigned int ULONG;

#ifndef C_ASSERT
- #define __UNIQUENAME( a1, a2 ) __CONCAT( a1, a2 )
+ #define __CONCATING( a1, a2 ) a1 ## a2
+ #define __UNIQUENAME( a1, a2 ) __CONCATING( a1, a2 )
#define UNIQUENAME( __text ) __UNIQUENAME( __text, __COUNTER__ )

#define STATIC_ASSERT(e) typedef char UNIQUENAME(STATIC_ASSERT_)[(e)?1:-1]
diff --git a/inc/common/UFO/portable_compiler.h b/inc/common/UFO/portable_compiler.h
index 81777765..d03fc69c 100644
--- a/inc/common/UFO/portable_compiler.h
+++ b/inc/common/UFO/portable_compiler.h
@@ -125,7 +125,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/* compile-time ASSERT */

#ifndef C_ASSERT
- #define __UNIQUENAME( a1, a2 ) __CONCAT( a1, a2 )
+ #define __CONCATING( a1, a2 ) a1 ## a2
+ #define __UNIQUENAME( a1, a2 ) __CONCATING( a1, a2 )
#define UNIQUENAME( __text ) __UNIQUENAME( __text, __COUNTER__ )


diff --git a/visa/BinaryEncodingCNL.h b/visa/BinaryEncodingCNL.h
index e301dc07..07c90cfd 100644
--- a/visa/BinaryEncodingCNL.h
+++ b/visa/BinaryEncodingCNL.h
@@ -46,8 +46,8 @@ typedef uint64_t QWORD;
#define BITFIELD_RANGE( startbit, endbit ) ((endbit)-(startbit)+1)
#define BITFIELD_BIT( bit ) 1

-#define __CONCAT(x,y) x ## y
-#define __UNIQUENAME( a1, a2 ) __CONCAT( a1, a2 )
+#define __CONCATING( a1, a2 ) a1 ## a2
+#define __UNIQUENAME( a1, a2 ) __CONCATING( a1, a2 )
#define UNIQUENAME( __text ) __UNIQUENAME( __text, __COUNTER__ )
#define STATIC_ASSERT(e) typedef char UNIQUENAME(STATIC_ASSERT_)[(e)?1:-1]

12 changes: 12 additions & 0 deletions L/libigc/bundled/patches/musl-inttypes.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/visa/CISA.y b/visa/CISA.y
index 6ab28ee3..25e08b04 100644
--- a/visa/CISA.y
+++ b/visa/CISA.y
@@ -29,6 +29,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <math.h>
#include <string>
#include <vector>
+#include <inttypes.h>

#include "visa_igc_common_header.h"
#include "Common_ISA.h"
11 changes: 11 additions & 0 deletions L/libigc/bundled/patches/musl-malloc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- mm_malloc.h
+++ mm_malloc.h
@@ -31,7 +31,7 @@
#ifndef __cplusplus
extern int posix_memalign (void **, size_t, size_t);
#else
-extern "C" int posix_memalign (void **, size_t, size_t) throw ();
+extern "C" int posix_memalign (void **, size_t, size_t);
#endif

static __inline void *