mirror of https://github.com/Jittor/Jittor
polish mac support for win_cuda
This commit is contained in:
parent
740b9c8552
commit
6938c25e19
|
@ -1022,11 +1022,23 @@ elif cc_type != 'cl':
|
|||
def fix_cl_flags(cmd):
|
||||
output = shsplit(cmd)
|
||||
output2 = []
|
||||
libpaths = []
|
||||
for s in output:
|
||||
if s.startswith("-l") and ("cpython" in s or "lib" in s):
|
||||
output2.append(f"-l:{s[2:]}.so")
|
||||
if platform.system() == 'Darwin':
|
||||
fname = s[2:] + ".so"
|
||||
for path in reversed(libpaths):
|
||||
full = os.path.join(path, fname).replace("\"", "")
|
||||
if os.path.isfile(full):
|
||||
output2.append(full)
|
||||
break
|
||||
else:
|
||||
output2.append(s)
|
||||
else:
|
||||
output2.append(f"-l:{s[2:]}.so")
|
||||
elif s.startswith("-L"):
|
||||
output2.append(f"{s} -Wl,-rpath={s[2:]}")
|
||||
libpaths.append(s[2:])
|
||||
output2.append(f"{s} -Wl,-rpath,{s[2:]}")
|
||||
else:
|
||||
output2.append(s)
|
||||
return " ".join(output2)
|
||||
|
|
|
@ -98,17 +98,40 @@ string fix_cl_flags(const string& cmd, bool is_cuda) {
|
|||
#else
|
||||
auto flags = shsplit(cmd);
|
||||
vector<string> output;
|
||||
#ifdef __APPLE__
|
||||
vector<string> libpaths;
|
||||
#endif
|
||||
|
||||
for (auto& f : flags) {
|
||||
if (startswith(f, "-l") &&
|
||||
(f.find("cpython") != string::npos ||
|
||||
f.find("lib") != string::npos))
|
||||
f.find("lib") != string::npos)) {
|
||||
#ifdef __APPLE__
|
||||
auto fname = f.substr(2) + ".so";
|
||||
int i;
|
||||
for (i=libpaths.size()-1; i>=0; i--) {
|
||||
auto full = libpaths[i] + '/' + fname;
|
||||
string full2;
|
||||
for (auto c : full)
|
||||
if (c != '\"') full2 += c;
|
||||
if (jit_compiler::file_exist(full2)) {
|
||||
output.push_back(full2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i<0) output.push_back(f);
|
||||
#else
|
||||
output.push_back("-l:"+f.substr(2)+".so");
|
||||
#endif
|
||||
}
|
||||
else if (startswith(f, "-L")) {
|
||||
if (is_cuda)
|
||||
output.push_back(f+" -Xlinker -rpath="+f.substr(2));
|
||||
else
|
||||
output.push_back(f+" -Wl,-rpath="+f.substr(2));
|
||||
output.push_back(f+" -Wl,-rpath,"+f.substr(2));
|
||||
#ifdef __APPLE__
|
||||
libpaths.push_back(f.substr(2));
|
||||
#endif
|
||||
} else
|
||||
output.push_back(f);
|
||||
}
|
||||
|
|
|
@ -529,10 +529,13 @@ int system_popen(const char* cmd, const char* cwd) {
|
|||
string output;
|
||||
while (fgets(buf, BUFSIZ, ptr) != NULL) {
|
||||
output += buf;
|
||||
std::cerr << buf;
|
||||
if (log_v)
|
||||
std::cerr << buf;
|
||||
}
|
||||
if (output.size()) std::cerr.flush();
|
||||
auto ret = pclose(ptr);
|
||||
if (ret && !log_v)
|
||||
std::cerr << output;
|
||||
if (output.size()<10 && ret) {
|
||||
// maybe overcommit
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue