mirror of
https://github.com/Relintai/osxcross.git
synced 2025-02-03 22:45:56 +01:00
Fix for #67
This commit is contained in:
parent
69b9d83d9b
commit
13240f3bd0
1
build.sh
1
build.sh
@ -149,6 +149,7 @@ pushd .. &>/dev/null
|
||||
popd &>/dev/null
|
||||
patch -p0 < $PATCH_DIR/cctools-ld64-1.patch
|
||||
patch -p0 < $PATCH_DIR/cctools-ld64-2.patch
|
||||
patch -p1 < $PATCH_DIR/cctools-ld64-linux-ncpus.patch
|
||||
echo ""
|
||||
CONFFLAGS="--prefix=$TARGET_DIR --target=x86_64-apple-$TARGET "
|
||||
CONFFLAGS+="--disable-clang-as "
|
||||
|
49
patches/cctools-ld64-linux-ncpus.patch
Normal file
49
patches/cctools-ld64-linux-ncpus.patch
Normal file
@ -0,0 +1,49 @@
|
||||
diff --git cctools/ld64/src/ld/InputFiles.cpp cctools/ld64/src/ld/InputFiles.cpp
|
||||
index 13207e5..2b6f7bd 100644
|
||||
--- cctools/ld64/src/ld/InputFiles.cpp
|
||||
+++ cctools/ld64/src/ld/InputFiles.cpp
|
||||
@@ -43,6 +43,15 @@
|
||||
#include <sys/sysctl.h>
|
||||
#include <libkern/OSAtomic.h>
|
||||
|
||||
+// ld64-port
|
||||
+#ifdef __linux__
|
||||
+#ifndef __USE_GNU
|
||||
+#define __USE_GNU
|
||||
+#endif
|
||||
+#include <sched.h>
|
||||
+#endif
|
||||
+// ld64-port end
|
||||
+
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <set>
|
||||
@@ -913,6 +922,20 @@ InputFiles::InputFiles(Options& opts, const char** archName)
|
||||
|
||||
// initialize info for parsing input files on worker threads
|
||||
unsigned int ncpus;
|
||||
+#ifdef __linux__ // ld64-port
|
||||
+ cpu_set_t cs;
|
||||
+ CPU_ZERO(&cs);
|
||||
+
|
||||
+ if (!sched_getaffinity(0, sizeof(cs), &cs)) {
|
||||
+ ncpus = 0;
|
||||
+
|
||||
+ for (int i = 0; i < CPU_SETSIZE; i++)
|
||||
+ if (CPU_ISSET(i, &cs))
|
||||
+ ncpus++;
|
||||
+ } else {
|
||||
+ ncpus = 1;
|
||||
+ }
|
||||
+#else
|
||||
int mib[2];
|
||||
size_t len = sizeof(ncpus);
|
||||
mib[0] = CTL_HW;
|
||||
@@ -920,6 +943,7 @@ InputFiles::InputFiles(Options& opts, const char** archName)
|
||||
if (sysctl(mib, 2, &ncpus, &len, NULL, 0) != 0) {
|
||||
ncpus = 1;
|
||||
}
|
||||
+#endif
|
||||
_availableWorkers = MIN(ncpus, files.size()); // max # workers we permit
|
||||
_idleWorkers = 0;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/***********************************************************************
|
||||
* OSXCross *
|
||||
* Copyright (C) 2013, 2014 by Thomas Poechtrager *
|
||||
* Copyright (C) 2013-2016 by Thomas Poechtrager *
|
||||
* t.poechtrager@gmail.com *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
@ -61,14 +61,15 @@ int getcpucount() {
|
||||
int i, cpucount = 0;
|
||||
|
||||
CPU_ZERO(&cs);
|
||||
sched_getaffinity(0, sizeof(cs), &cs);
|
||||
|
||||
for (i = 0; i < 128; i++) {
|
||||
if (sched_getaffinity(0, sizeof(cs), &cs))
|
||||
return 1;
|
||||
|
||||
for (i = 0; i < CPU_SETSIZE; i++)
|
||||
if (CPU_ISSET(i, &cs))
|
||||
cpucount++;
|
||||
}
|
||||
|
||||
return cpucount ? cpucount : 1;
|
||||
return cpucount;
|
||||
#else
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || \
|
||||
defined(__OpenBSD__) || defined(__DragonFly__) || \
|
||||
|
Loading…
Reference in New Issue
Block a user