Skip to content

Commit 70d1fe2

Browse files
committed
Trying to unify the behavior of wllvm and gllvm when compiling the linux kernel.
1 parent ef21020 commit 70d1fe2

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

wllvm/compilers.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,19 @@ def attachBitcodePathToObject(bcPath, outFileName):
103103
# that won't work.
104104
(_, ext) = os.path.splitext(outFileName)
105105
_logger.debug('attachBitcodePathToObject: %s ===> %s [ext = %s]', bcPath, outFileName, ext)
106-
#iam: this also looks very dodgey; we need a more reliable way to do this:
107-
if ext not in ('.o', '.lo', '.os', '.So', '.po'):
108-
_logger.warning('Cannot attach bitcode path to "%s of type %s"', outFileName, FileType.getFileType(outFileName))
106+
107+
#iam: just object files, right?
108+
fileType = FileType.getFileType(outFileName)
109+
if fileType not in (FileType.MACH_OBJECT, FileType.ELF_OBJECT):
110+
#if fileType not in (FileType.MACH_OBJECT, FileType.MACH_SHARED, FileType.ELF_OBJECT, FileType.ELF_SHARED):
111+
_logger.warning('Cannot attach bitcode path to "%s of type %s"', outFileName, FileType.getReadableFileType(fileType))
109112
return
110113

114+
#iam: this also looks very dodgey; we need a more reliable way to do this:
115+
#if ext not in ('.o', '.lo', '.os', '.So', '.po'):
116+
# _logger.warning('Cannot attach bitcode path to "%s of type %s"', outFileName, FileType.getReadableFileType(outFileName))
117+
# return
118+
111119
# Now just build a temporary text file with the full path to the
112120
# bitcode file that we'll write into the object file.
113121
f = tempfile.NamedTemporaryFile(mode='w+b', delete=False)

wllvm/filetype.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ def getFileType(cls, fileName):
5656

5757
return retval
5858

59+
60+
@classmethod
61+
def getFileTypeString(cls, fti):
62+
""" Returns the string name of the file type.
63+
64+
"""
65+
if fti in cls.revMap:
66+
return cls.revMap[fti]
67+
else:
68+
'UNKNOWN'
69+
5970
@classmethod
6071
def init(cls):
6172
""" Initializes the static fields.

0 commit comments

Comments
 (0)