Skip to content

Commit

Permalink
[LLDB] Unit tests basic support for OpenBSD
Browse files Browse the repository at this point in the history
Add OpenBSD python module in order to support unit tests.

Reviewers: labath, zturner

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D47692

llvm-svn: 333888
  • Loading branch information
devnexen committed Jun 4, 2018
1 parent 7b53d14 commit 15aefbd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
4 changes: 4 additions & 0 deletions lldb/lit/lit.cfg
Expand Up @@ -78,6 +78,10 @@ if platform.system() in ['Darwin']:
config.cc += " -isysroot %s" % sdk_path
config.cxx += " -isysroot %s" % sdk_path

if platform.system() in ['OpenBSD']:
config.cc += " -pthread"
config.cxx += " -pthread"

config.substitutions.append(('%cc', config.cc))
config.substitutions.append(('%cxx', config.cxx))

Expand Down
34 changes: 19 additions & 15 deletions lldb/packages/Python/lldbsuite/test/lldbtest.py
Expand Up @@ -490,6 +490,8 @@ def getsource_if_available(obj):
def builder_module():
if sys.platform.startswith("freebsd"):
return __import__("builder_freebsd")
if sys.platform.startswith("openbsd"):
return __import__("builder_openbsd")
if sys.platform.startswith("netbsd"):
return __import__("builder_netbsd")
if sys.platform.startswith("linux"):
Expand Down Expand Up @@ -1395,7 +1397,7 @@ def getDebugInfo(self):

def getstdlibFlag(self):
""" Returns the proper -stdlib flag, or empty if not required."""
if self.platformIsDarwin() or self.getPlatform() == "freebsd":
if self.platformIsDarwin() or self.getPlatform() == "freebsd" or self.getPlatform() == "openbsd":
stdlibflag = "-stdlib=libc++"
else: # this includes NetBSD
stdlibflag = ""
Expand Down Expand Up @@ -1424,7 +1426,7 @@ def buildDriver(self, sources, exe_name):
'FRAMEWORK_INCLUDES': "-F%s" % self.framework_dir,
'LD_EXTRAS': "%s -Wl,-rpath,%s" % (self.dsym, self.framework_dir),
}
elif sys.platform.rstrip('0123456789') in ('freebsd', 'linux', 'netbsd', 'darwin') or os.environ.get('LLDB_BUILD_TYPE') == 'Makefile':
elif sys.platform.startswith('win'):
d = {
'CXX_SOURCES': sources,
'EXE': exe_name,
Expand All @@ -1433,8 +1435,8 @@ def buildDriver(self, sources, exe_name):
os.path.join(
os.environ["LLDB_SRC"],
"include")),
'LD_EXTRAS': "-L%s/../lib -llldb -Wl,-rpath,%s/../lib" % (lib_dir, lib_dir)}
elif sys.platform.startswith('win'):
'LD_EXTRAS': "-L%s -lliblldb" % os.environ["LLDB_IMPLIB_DIR"]}
else:
d = {
'CXX_SOURCES': sources,
'EXE': exe_name,
Expand All @@ -1443,7 +1445,7 @@ def buildDriver(self, sources, exe_name):
os.path.join(
os.environ["LLDB_SRC"],
"include")),
'LD_EXTRAS': "-L%s -lliblldb" % os.environ["LLDB_IMPLIB_DIR"]}
'LD_EXTRAS': "-L%s/../lib -llldb -Wl,-rpath,%s/../lib" % (lib_dir, lib_dir)}
if self.TraceOn():
print(
"Building LLDB Driver (%s) from sources %s" %
Expand All @@ -1464,15 +1466,6 @@ def buildLibrary(self, sources, lib_name):
'FRAMEWORK_INCLUDES': "-F%s" % self.framework_dir,
'LD_EXTRAS': "%s -Wl,-rpath,%s -dynamiclib" % (self.dsym, self.framework_dir),
}
elif sys.platform.rstrip('0123456789') in ('freebsd', 'linux', 'netbsd', 'darwin') or os.environ.get('LLDB_BUILD_TYPE') == 'Makefile':
d = {
'DYLIB_CXX_SOURCES': sources,
'DYLIB_NAME': lib_name,
'CFLAGS_EXTRAS': "%s -I%s -fPIC" % (stdflag,
os.path.join(
os.environ["LLDB_SRC"],
"include")),
'LD_EXTRAS': "-shared -L%s/../lib -llldb -Wl,-rpath,%s/../lib" % (lib_dir, lib_dir)}
elif self.getPlatform() == 'windows':
d = {
'DYLIB_CXX_SOURCES': sources,
Expand All @@ -1482,6 +1475,15 @@ def buildLibrary(self, sources, lib_name):
os.environ["LLDB_SRC"],
"include")),
'LD_EXTRAS': "-shared -l%s\liblldb.lib" % self.os.environ["LLDB_IMPLIB_DIR"]}
else:
d = {
'DYLIB_CXX_SOURCES': sources,
'DYLIB_NAME': lib_name,
'CFLAGS_EXTRAS': "%s -I%s -fPIC" % (stdflag,
os.path.join(
os.environ["LLDB_SRC"],
"include")),
'LD_EXTRAS': "-shared -L%s/../lib -llldb -Wl,-rpath,%s/../lib" % (lib_dir, lib_dir)}
if self.TraceOn():
print(
"Building LLDB Library (%s) from sources %s" %
Expand Down Expand Up @@ -1672,6 +1674,8 @@ def getBuildFlags(
cflags += "c++11"
if self.platformIsDarwin() or self.getPlatform() == "freebsd":
cflags += " -stdlib=libc++"
elif self.getPlatform() == "openbsd":
cflags += " -stdlib=libc++"
elif self.getPlatform() == "netbsd":
cflags += " -stdlib=libstdc++"
elif "clang" in self.getCompiler():
Expand Down Expand Up @@ -1706,7 +1710,7 @@ def getLLDBLibraryEnvVal(self):
return lib_dir

def getLibcPlusPlusLibs(self):
if self.getPlatform() in ('freebsd', 'linux', 'netbsd'):
if self.getPlatform() in ('freebsd', 'linux', 'netbsd', 'openbsd'):
return ['libc++.so.1']
else:
return ['libc++.1.dylib', 'libc++abi.dylib']
Expand Down

0 comments on commit 15aefbd

Please sign in to comment.