Skip to content

Commit

Permalink
Merge pull request #26358 from tkelman/tk/fix-alpine-build
Browse files Browse the repository at this point in the history
Fix build from source on alpine linux
  • Loading branch information
ararslan authored Apr 1, 2018
2 parents daadf4a + 19dd3b9 commit 8131c75
Show file tree
Hide file tree
Showing 9 changed files with 8,594 additions and 2 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
- run: | # checkout merge commit, set versioning info and Make.user variables
git config --global --unset url."ssh://[email protected]".insteadOf &&
if [ -n "$CIRCLE_PULL_REQUEST" ]; then
git remote set-url origin [email protected]:JuliaLang/julia.git &&
git fetch origin +refs/pull/$(basename $CIRCLE_PULL_REQUEST)/merge &&
git checkout -qf FETCH_HEAD;
fi &&
Expand Down
8 changes: 7 additions & 1 deletion deps/blas.mk
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ endif
# Do not overwrite the "-j" flag
OPENBLAS_BUILD_OPTS += MAKE_NB_JOBS=0

$(BUILDDIR)/$(OPENBLAS_SRC_DIR)/build-configured: $(BUILDDIR)/$(OPENBLAS_SRC_DIR)/source-extracted
# Fix build on musl libc, from https://github.com/xianyi/OpenBLAS/pull/1257
# remove when upgrading past openblas v0.2.20
$(BUILDDIR)/$(OPENBLAS_SRC_DIR)/openblas-musl-PR1257.patch-applied: $(BUILDDIR)/$(OPENBLAS_SRC_DIR)/source-extracted
cd $(BUILDDIR)/$(OPENBLAS_SRC_DIR) && patch -p1 -f < $(SRCDIR)/patches/openblas-musl-PR1257.patch
echo 1 > $@

$(BUILDDIR)/$(OPENBLAS_SRC_DIR)/build-configured: $(BUILDDIR)/$(OPENBLAS_SRC_DIR)/openblas-musl-PR1257.patch-applied
perl -i -ple 's/^\s*(EXTRALIB\s*\+=\s*-lSystemStubs)\s*$$/# $$1/g' $(dir $<)/Makefile.system
echo 1 > $@

Expand Down
5 changes: 5 additions & 0 deletions deps/llvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ $(eval $(call LLVM_PATCH,llvm-3.9-c_api_nullptr))
$(eval $(call LLVM_PATCH,llvm-PPC-addrspaces)) # PPC
$(eval $(call LLVM_PATCH,llvm-D30114)) # PPC remove for 5.0
$(eval $(call LLVM_PATCH,llvm-PR36292)) # PPC fixes #26249, remove for 6.0
$(eval $(call LLVM_PATCH,llvm-D39297-musl-dynamiclibrary-pre5)) # Remove for 6.0
$(eval $(call LLVM_PATCH,llvm-D28476-musl-targetlibraryinfo_3.9)) # Remove for 5.0
ifeq ($(BUILD_LLVM_CLANG),1)
$(eval $(call LLVM_PATCH,compiler_rt-3.9-glibc_2.25.90)) # Remove for 5.0
endif
Expand Down Expand Up @@ -498,6 +500,8 @@ $(eval $(call LLVM_PATCH,llvm-D42262-jumpthreading-not-i1))
$(eval $(call LLVM_PATCH,llvm-PPC-addrspaces)) # PPC
$(eval $(call LLVM_PATCH,llvm-D30114)) # PPC remove for 5.0
$(eval $(call LLVM_PATCH,llvm-PR36292)) # PPC fixes #26249, remove for 6.0
$(eval $(call LLVM_PATCH,llvm-D39297-musl-dynamiclibrary-pre5)) # Remove for 6.0
$(eval $(call LLVM_PATCH,llvm-D28476-musl-targetlibraryinfo_4.0)) # Remove for 5.0
ifeq ($(BUILD_LLVM_CLANG),1)
$(eval $(call LLVM_PATCH,compiler_rt-3.9-glibc_2.25.90)) # Remove for 5.0
endif
Expand All @@ -514,6 +518,7 @@ $(eval $(call LLVM_PATCH,llvm-D38765-gvn_5.0)) # Remove for 6.0
$(eval $(call LLVM_PATCH,llvm-D42262-jumpthreading-not-i1)) # remove for 7.0
$(eval $(call LLVM_PATCH,llvm-PPC-addrspaces)) # PPC
$(eval $(call LLVM_PATCH,llvm-PR36292-5.0)) # PPC fixes #26249, remove for 6.0
$(eval $(call LLVM_PATCH,llvm-D39297-musl-dynamiclibrary)) # Remove for 6.0
else ifeq ($(LLVM_VER_SHORT),6.0)
$(eval $(call LLVM_PATCH,llvm-D27629-AArch64-large_model_4.0))
$(eval $(call LLVM_PATCH,llvm-D34078-vectorize-fdiv))
Expand Down
3,955 changes: 3,955 additions & 0 deletions deps/patches/llvm-D28476-musl-targetlibraryinfo_3.9.patch

Large diffs are not rendered by default.

4,480 changes: 4,480 additions & 0 deletions deps/patches/llvm-D28476-musl-targetlibraryinfo_4.0.patch

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions deps/patches/llvm-D39297-musl-dynamiclibrary-pre5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
From ae8900a8833835309aecb0a3d947c2ae46fd86c3 Mon Sep 17 00:00:00 2001
From: Keno Fischer <[email protected]>
Date: Thu, 26 Oct 2017 16:44:13 +0000
Subject: [PATCH] [DynamicLibrary] Fix build on musl libc

Summary:
On musl libc, stdin/out/err are defined as `FILE* const` globals,
and their address is not implicitly convertible to void *,
or at least gcc 6 doesn't allow it, giving errors like:

```
error: cannot initialize return object of type 'void *' with an rvalue of type 'FILE *const *' (aka '_IO_FILE *const *')
EXPLICIT_SYMBOL(stderr);
^~~~~~~~~~~~~~~~~~~~~~~
```

Add an explicit cast to fix that problem.

Reviewers: marsupial, krytarowski, dim
Reviewed By: dim
Differential Revision: https://reviews.llvm.org/D39297

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316672 91177308-0d34-0410-b5e6-96231b3b80d8
---
lib/Support/Unix/DynamicLibrary.inc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Support/Unix/DynamicLibrary.inc b/lib/Support/Unix/DynamicLibrary.inc
index f05103ccd1eb..029451f347e8 100644
--- a/lib/Support/DynamicLibrary.cpp
+++ b/lib/Support/DynamicLibrary.cpp
@@ -71,7 +71,7 @@ void *DynamicLibrary::HandleSet::DLSym(void *Handle, const char *Symbol) {

// This macro returns the address of a well-known, explicit symbol
#define EXPLICIT_SYMBOL(SYM) \
- if (!strcmp(symbolName, #SYM)) return &SYM
+ if (!strcmp(symbolName, #SYM)) return (void*)&SYM

// On linux we have a weird situation. The stderr/out/in symbols are both
// macros and global variables because of standards requirements. So, we
40 changes: 40 additions & 0 deletions deps/patches/llvm-D39297-musl-dynamiclibrary.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
From ae8900a8833835309aecb0a3d947c2ae46fd86c3 Mon Sep 17 00:00:00 2001
From: Keno Fischer <[email protected]>
Date: Thu, 26 Oct 2017 16:44:13 +0000
Subject: [PATCH] [DynamicLibrary] Fix build on musl libc

Summary:
On musl libc, stdin/out/err are defined as `FILE* const` globals,
and their address is not implicitly convertible to void *,
or at least gcc 6 doesn't allow it, giving errors like:

```
error: cannot initialize return object of type 'void *' with an rvalue of type 'FILE *const *' (aka '_IO_FILE *const *')
EXPLICIT_SYMBOL(stderr);
^~~~~~~~~~~~~~~~~~~~~~~
```

Add an explicit cast to fix that problem.

Reviewers: marsupial, krytarowski, dim
Reviewed By: dim
Differential Revision: https://reviews.llvm.org/D39297

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316672 91177308-0d34-0410-b5e6-96231b3b80d8
---
lib/Support/Unix/DynamicLibrary.inc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Support/Unix/DynamicLibrary.inc b/lib/Support/Unix/DynamicLibrary.inc
index f05103ccd1eb..029451f347e8 100644
--- a/lib/Support/Unix/DynamicLibrary.inc
+++ b/lib/Support/Unix/DynamicLibrary.inc
@@ -71,7 +71,7 @@ void *DynamicLibrary::HandleSet::DLSym(void *Handle, const char *Symbol) {
// Must declare the symbols in the global namespace.
static void *DoSearch(const char* SymbolName) {
#define EXPLICIT_SYMBOL(SYM) \
- extern void *SYM; if (!strcmp(SymbolName, #SYM)) return &SYM
+ extern void *SYM; if (!strcmp(SymbolName, #SYM)) return (void*)&SYM

// If this is darwin, it has some funky issues, try to solve them here. Some
// important symbols are marked 'private external' which doesn't allow
65 changes: 65 additions & 0 deletions deps/patches/openblas-musl-PR1257.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
From 63cfa32691680505e6b9daf0997755178ddd3144 Mon Sep 17 00:00:00 2001
From: Martin Kroeker <[email protected]>
Date: Mon, 31 Jul 2017 21:02:43 +0200
Subject: [PATCH] Rework __GLIBC_PREREQ checks to avoid breaking non-glibc
builds

---
driver/others/memory.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/driver/others/memory.c b/driver/others/memory.c
index b5b58b6fd..661f7c4eb 100644
--- a/driver/others/memory.c
+++ b/driver/others/memory.c
@@ -155,7 +155,6 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifdef DYNAMIC_ARCH
gotoblas_t *gotoblas = NULL;
#endif
-
extern void openblas_warning(int verbose, const char * msg);

#ifndef SMP
@@ -187,25 +186,24 @@ int i,n;

#if !defined(__GLIBC_PREREQ)
return nums;
-#endif
-#if !__GLIBC_PREREQ(2, 3)
+#else
+ #if !__GLIBC_PREREQ(2, 3)
return nums;
-#endif
+ #endif

-#if !__GLIBC_PREREQ(2, 7)
+ #if !__GLIBC_PREREQ(2, 7)
ret = sched_getaffinity(0,sizeof(cpu_set_t), cpusetp);
if (ret!=0) return nums;
n=0;
-#if !__GLIBC_PREREQ(2, 6)
+ #if !__GLIBC_PREREQ(2, 6)
for (i=0;i<nums;i++)
if (CPU_ISSET(i,cpusetp)) n++;
nums=n;
-#else
+ #else
nums = CPU_COUNT(sizeof(cpu_set_t),cpusetp);
-#endif
+ #endif
return nums;
-#endif
-
+ #else
cpusetp = CPU_ALLOC(nums);
if (cpusetp == NULL) return nums;
size = CPU_ALLOC_SIZE(nums);
@@ -214,6 +212,8 @@ int i,n;
nums = CPU_COUNT_S(size,cpusetp);
CPU_FREE(cpusetp);
return nums;
+ #endif
+#endif
}
#endif
#endif
2 changes: 1 addition & 1 deletion deps/tools/jldownload
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ CACHE_URL="$CACHE_HOST/$URL"

if [ -x "$CURL" ] && $CURL -V >/dev/null; then
GETURL="$CURL $CURL_OPTS"
elif [ -x "$WGET" ] && $WGET -V >/dev/null; then
elif [ -x "$WGET" ] && $WGET --help >/dev/null 2>&1; then
GETURL="$WGET $WGET_OPTS"
elif [ -x "$FETCH" ]; then
GETURL="$FETCH $FETCH_OPTS"
Expand Down

2 comments on commit 8131c75

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

Please sign in to comment.