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

[WIP] Some more Catalina fixes #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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: 6 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,15 @@ $(SYMROOT_MADE): $(OBJROOT_MADE)
$(TOUCH) $@

# Subdirectories
CLANG_VERS = clang-39
CLANG_BRANCH = tags/RELEASE_391/final
CLANG_VERS = clang-50
CLANG_BRANCH = llvmorg-5.0.0
CLANG_DIR = $(OBJROOT)/$(CLANG_VERS)
SWIG_DIR = $(OBJROOT)/swig

CLANG_DIR_MADE = $(CLANG_DIR)/$(MADEFILE)
$(CLANG_DIR_MADE): $(OBJROOT_MADE)
mkdir -p $(OBJROOT)
# cd $(OBJROOT) && git clone https://github.com/llvm-mirror/llvm.git $(CLANG_VERS) && cd $(CLANG_DIR) && git checkout -b $(CLANG_BRANCH) origin/$(CLANG_BRANCH)
# cd $(CLANG_DIR)/tools && git clone https://github.com/llvm-mirror/clang.git && cd $(CLANG_DIR)/tools/clang && git checkout -b $(CLANG_BRANCH) origin/$(CLANG_BRANCH)
# cd $(CLANG_DIR)/projects && git clone https://github.com/llvm-mirror/compiler-rt.git && cd $(CLANG_DIR)/projects/compiler-rt && git checkout -b $(CLANG_BRANCH) origin/$(CLANG_BRANCH)
cd $(OBJROOT) && svn co http://llvm.org/svn/llvm-project/llvm/$(CLANG_BRANCH) $(CLANG_VERS)
cd $(CLANG_DIR)/tools && svn co http://llvm.org/svn/llvm-project/cfe/$(CLANG_BRANCH) clang
cd $(CLANG_DIR)/projects && svn co http://llvm.org/svn/llvm-project/compiler-rt/$(CLANG_BRANCH) compiler-rt
cd $(OBJROOT) && git clone git@github.com:llvm/llvm-project.git -b $(CLANG_BRANCH) $(CLANG_VERS)
cd $(CLANG_DIR)/tools/clang && patch -p0 < $(SRCROOT)/clang.patch
cd $(SRCROOT)
$(TOUCH) $@
Expand Down Expand Up @@ -130,7 +125,7 @@ $(CLANGROOT_MADE): $(CLANG_DIR_MADE)
$(MKDIR) $(CLANG_DIR)/darwin-$$arch && \
(cd $(CLANG_DIR)/darwin-$$arch && \
$(MKDIR) ROOT && \
env MACOSX_DEPLOYMENT_TARGET=10.9 CC="$(CC) -arch $$arch" CXX="$(CXX) -arch $$arch" cmake ../ -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_LIBCXX=YES -DLLVM_BUILD_EXTERNAL_COMPILER_RT=YES -DLLVM_TARGETS_TO_BUILD="X86" && \
env MACOSX_DEPLOYMENT_TARGET=10.9 CC="$(CC) -arch $$arch" CXX="$(CXX) -arch $$arch" cmake ../llvm -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi" -DLLVM_BUILD_EXTERNAL_COMPILER_RT=YES -DLLVM_TARGETS_TO_BUILD="X86" && \
env MACOSX_DEPLOYMENT_TARGET=10.9 CC="$(CC) -arch $$arch" CXX="$(CXX) -arch $$arch" make -j$(shell sysctl -n hw.ncpu) && \
$(MKDIR) $(CLANG_DIR)/darwin-$$arch/ROOT && \
make install DESTDIR=$(CLANG_DIR)/darwin-$$arch/ROOT) || exit 1; \
Expand All @@ -156,7 +151,7 @@ $(BS_RUBY_MADE): $(CLANGROOT_MADE) $(SWIG_DIR_MADE) $(DSTROOT_MADE) $(SYMROOT_MA
@/bin/echo -n '*** Started Building bridgesupport.bundle: ' && date
@set -x && \
cd $(SWIG_DIR) && \
make LLVM-CONFIG=$(CLANGROOT)$(CLANG_PREFIX)/local/bin/llvm-config RC_CFLAGS='$(RC_CFLAGS)' && \
make VERBOSE=1 LLVM-CONFIG=$(CLANGROOT)$(CLANG_PREFIX)/local/bin/llvm-config RC_CFLAGS='$(RC_CFLAGS)' && \
$(MKDIR) $(BS_RUBY) && \
$(RSYNC) bridgesupportparser.bundle* $(SYMROOT) && \
$(RSYNC) bridgesupportparser.bundle $(BS_RUBY) && \
Expand Down Expand Up @@ -195,7 +190,7 @@ $(LIBSYSTEM_BRIDGESUPPORT):
@/bin/echo -n '*** Started Building .bridgesupport files: ' && date
# TODO : generate BridgeSupport files in each system library frameworks
# DSTROOT='$(DSTROOT)' RUBYLIB='$(RUBYLIB)' $(RUBY) build.rb
RUBYLIB='$(RUBYLIB)' $(RUBY) gen_bridge_metadata.rb -c '-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/CommonCrypto -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include' -e $(LIBSYSTEM_EXCEPTION) -o $@ $(LIBSYSTEM_HEADERS)
RUBYLIB='$(RUBYLIB)' $(RUBY) gen_bridge_metadata.rb -c '-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/CommonCrypto -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include' -e $(LIBSYSTEM_EXCEPTION) -o $@ $(LIBSYSTEM_HEADERS) -d
$(INSTALL_DIRECTORY) $(SYSTEM_BRIDGESUPPORT)
$(LN) -fs `echo $(SYSTEM_BS) | sed 's,[^/]*,..,g'`/BridgeSupport/libSystem.bridgesupport $(SYSTEM_BRIDGESUPPORT)/System.bridgesupport
@/bin/echo -n '*** Finished Building .bridgesupport files: ' && date
Expand Down
2 changes: 1 addition & 1 deletion gen_bridge_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ def _parse(args, arch, ignore_merge_errors = false)

def makedarwinvers(vers)
pieces = vers.split('.')
raise "Version \"#{vers}\" not 10.x[.y]" if pieces.length < 2 || pieces.length > 3 || pieces[0] != '10' || pieces[1] !~ /^\d+$/ || (pieces.length == 3 && pieces[2] !~ /^\d+$/)
raise "Version \"#{vers}\" not 10.x[.y] or 11.x[.y]" if pieces.length < 2 || pieces.length > 3 || (pieces[0] != '10' && pieces[0] != '11') || pieces[1] !~ /^\d+$/ || (pieces.length == 3 && pieces[2] !~ /^\d+$/)
pieces << '0' if pieces.length == 2
return sprintf('%d.%s', pieces[1].to_i + 4, pieces[2])
end
Expand Down
14 changes: 7 additions & 7 deletions swig/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ SHELL = /bin/sh
ruby_version = 2.6
ruby_abi_version = 2.6.0
usrlib = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include
topdir = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin19
topdir = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin20
hdrdir = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0
confdir = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin19
confdir = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin20

srcdir = .
VPATH = $(srcdir):$(topdir):$(hdrdir)
exec_prefix = $(prefix)
prefix = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr
exec_prefix = $(prefix)
sharedstatedir = $(prefix)/com
mandir = $(DESTDIR)/usr/share/man
psdir = $(docdir)
Expand Down Expand Up @@ -54,7 +54,7 @@ RUBY_EXTCONF_H =
LLVM-CONFIG = llvm-config
CFLAGS = $(RC_CFLAGS) -mmacosx-version-min=10.9 $(shell $(LLVM-CONFIG) --cxxflags | sed -e 's/ *-arch [^ ]*//g' -e 's/ *-D[^ ]*//g')

INCFLAGS = -I$(usrlib) -I. -I$(topdir) -I$(hdrdir) -I$(confdir) -I$(srcdir)
INCFLAGS = -isystem$(usrlib) -I. -isystem$(topdir) -isystem$(hdrdir) -isystem$(confdir) -I$(srcdir)
DEFS =
CPPFLAGS = $(shell $(LLVM-CONFIG) --cppflags | sed 's/ *-arch [^ ]*//g')

Expand All @@ -73,8 +73,8 @@ RUBY_SO_NAME = ruby
arch = $(shell $(RUBY) -e 'puts RUBY_PLATFORM')
sitearch = $(arch)

ruby = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/$(ruby_version)/usr/bin/ruby
RUBY = $(ruby)
#ruby = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/$(ruby_version)/usr/bin/ruby
RUBY = /usr/bin/ruby #$(ruby)
RM = rm -f
MAKEDIRS = mkdir -p
INSTALL = /usr/bin/install -c
Expand All @@ -97,7 +97,7 @@ extout =
extout_prefix =
target_prefix =
LOCAL_LIBS =
LIBS = $(LIBRUBYARG_SHARED) -lclangCodeGen -lclangAnalysis -lclangARCMigrate -lclangRewriteFrontend -lclangSema -lclangSerialization -lclangFrontend -lclangEdit -lclangDriver -lclangAST -lclangParse -lclangLex -lclangBasic -lLLVMCore -lLLVMSupport -lLLVMBitWriter -lLLVMBitReader -lLLVMCodeGen -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMMCParser -lLLVMOption -lLLVMProfileData -lz -lcurses
LIBS = $(LIBRUBYARG_SHARED) -lclangCodeGen -lclangAnalysis -lclangARCMigrate -lclangRewriteFrontend -lclangSema -lclangSerialization -lclangFrontend -lclangEdit -lclangDriver -lclangAST -lclangParse -lclangLex -lclangBasic -lLLVMBinaryFormat -lLLVMCore -lLLVMDemangle -lLLVMSupport -lLLVMBitWriter -lLLVMBitReader -lLLVMCodeGen -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMMCParser -lLLVMOption -lLLVMProfileData -lz -lcurses
SRCS = bridgesupportparser.cpp bridgesupportparser_wrap.cpp
OBJS = bridgesupportparser.o bridgesupportparser_wrap.o
TARGET = bridgesupportparser
Expand Down
15 changes: 8 additions & 7 deletions swig/bridgesupportparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ locgetpath(SourceManager *sm, SourceLocation sl)
FileID fid = sm->getFileID(sl);
if(fid == sm->getMainFileID()) return CONTENT;
fe = sm->getFileEntryForID(fid);
if(!fe || !(path = fe->getName())) path = "/dev/null";
if(!fe || !(path = fe->getName().str().c_str())) path = "/dev/null";
return path;
}

Expand Down Expand Up @@ -950,14 +950,15 @@ BridgeSupportParser::~BridgeSupportParser()
void
BridgeSupportParser::addFile(const char *file) {
const DirectoryLookup *CurDir;
bool isMapped;
SmallVector<std::pair<const FileEntry *, const DirectoryEntry *>, 0> Includers;
const FileEntry *fe = compiler.getPreprocessor().getHeaderSearchInfo().LookupFile(file, SourceLocation(), false, NULL, CurDir, Includers, NULL, NULL, NULL, NULL);
const FileEntry *fe = compiler.getPreprocessor().getHeaderSearchInfo().LookupFile(file, SourceLocation(), false, NULL, CurDir, Includers, NULL, NULL, NULL, NULL, &isMapped);
if(!fe)
rb_raise(rb_eRuntimeError, "addFile: Couldn't lookup file: %s", file);
char path[PATH_MAX];
if(realpath(fe->getName(), path) == NULL) {
if(realpath(fe->getName().str().c_str(), path) == NULL) {
int saveerrno = errno;
snprintf(path, sizeof(path), "addFile: realpath: %s", fe->getName());
snprintf(path, sizeof(path), "addFile: realpath: %s", fe->getName().str().c_str());
errno = saveerrno;
rb_sys_fail(path);
}
Expand All @@ -979,9 +980,9 @@ BridgeSupportParser::inDir(FileID file) {
const clang::FileEntry *fe = compiler.getSourceManager().getFileEntryForID(file);
char path[PATH_MAX];
if(fe) {
if(realpath(fe->getName(), path) == NULL) {
if(realpath(fe->getName().str().c_str(), path) == NULL) {
int saveerrno = errno;
snprintf(path, sizeof(path), "inDir: realpath: %s", fe->getName());
snprintf(path, sizeof(path), "inDir: realpath: %s", fe->getName().str().c_str());
errno = saveerrno;
rb_sys_fail(path);
}
Expand Down Expand Up @@ -1545,7 +1546,7 @@ AnObjCMethod::info()
{
//std::string type = MD->getResultType().isNull() ? "id" : MD->getResultType().getAsString();
std::string menc, retenc;
BSP->compiler.getASTContext().getObjCEncodingForMethodDecl(MD, menc);
menc = BSP->compiler.getASTContext().getObjCEncodingForMethodDecl(MD);
QualType rettype = MD->getReturnType();
BSP->getObjCEncodingForType(rettype, retenc);
if(rettype->isFunctionPointerType() || rettype->isBlockPointerType()) {
Expand Down