Skip to content

Commit 787fca4

Browse files
committed
Dragonegg compiles apache on my vagrant box now, perhaps it will also compile on travis?
1 parent 47f7d41 commit 787fca4

File tree

5 files changed

+70
-14
lines changed

5 files changed

+70
-14
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ python:
88
install:
99
- sudo apt-get update
1010
- sudo apt-get install llvm-3.4 clang-3.4 libapr1-dev libaprutil1-dev
11-
- sudo apt-get install dragonegg llvm-3.3 llvm-gcc
11+
- sudo apt-get install dragonegg llvm-3.0 llvm-gcc
1212
- export WLLVM_HOME=`pwd`
1313

1414
# command to run tests
1515
script:
1616
# build apache with clang (i.e. httpd-2.4.12)
1717
- ${WLLVM_HOME}/.travis/apache_clang.sh
18-
# when it works we can uncomment this puppy out
18+
# build apache with gcc and dragonegg (i.e. httpd-2.4.12)
1919
# - ${WLLVM_HOME}/.travis/apache_dragonegg.sh
2020

2121

.travis/apache_dragonegg.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Make sure we exit if there is a failure
33
set -e
44

5+
export dragonegg_disable_version_check=true
56

67
export PATH=/usr/lib/llvm-3.0/bin:${WLLVM_HOME}:${PATH}
78
export LLVM_COMPILER=dragonegg

driver/as

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,15 @@ except AttributeError as e:
5353
logging.error('Output file argument not found.\nException message: ' + str(e))
5454
sys.exit(1)
5555

56-
bcfilename = '.{0}.bc'.format(filename)
57-
bcPath = os.path.join(dirs, bcfilename)
58-
fakeAssembler = [llvmAssembler, infile, '-o', bcPath]
56+
fakeAssembler = [llvmAssembler, infile, '-o', argFilter.outFileName]
57+
5958
asmProc = Popen(fakeAssembler)
6059
realRet = asmProc.wait()
6160

6261
if realRet != 0:
6362
logging.error('llvm-as failed')
6463
sys.exit(realRet)
6564

66-
attachBitcodePathToObject(bcPath, argFilter.outFileName)
67-
6865
sys.exit(realRet)
6966

7067

driver/utils.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
184184
'-current_version' : (1, ArgumentListFilter.linkBinaryCallback),
185185
'-compatibility_version' : (1, ArgumentListFilter.linkBinaryCallback),
186186

187+
# dragonegg mystery argument
188+
'--64' : (0, ArgumentListFilter.compileUnaryCallback),
189+
187190
#
188191
# BD: need to warn the darwin user that these flags will rain on their parade
189192
# (the Darwin ld is a bit single minded)
@@ -455,6 +458,8 @@ def attachBitcodePathToObject(bcPath, outFileName):
455458
# Don't try to attach a bitcode path to a binary. Unfortunately
456459
# that won't work.
457460
(root, ext) = os.path.splitext(outFileName)
461+
if DEBUG:
462+
print('attachBitcodePathToObject: {0} ===> {1} [ext = {2}]\n'.format(bcPath, outFileName, ext))
458463
#iam: this also looks very dodgey; we need a more reliable way to do this:
459464
if ext not in ('.o', '.lo', '.os', '.So', '.po'):
460465
_logger.warning('Cannot attach bitcode path to "{0} of type {1}"'.format(outFileName, FileType.getFileType(outFileName)))
@@ -520,6 +525,12 @@ def __init__(self, cmd, isCxx, prefixPath=None):
520525
else:
521526
self.prefixPath = ''
522527

528+
#clang and drogonegg share the same taste in bitcode filenames.
529+
def getBitcodeFileName(self, argFilter):
530+
(dirs, baseFile) = os.path.split(argFilter.getOutputFilename())
531+
bcfilename = os.path.join(dirs, '.{0}.bc'.format(baseFile))
532+
return bcfilename
533+
523534
class ClangBuilder(BuilderBase):
524535
def __init__(self, cmd, isCxx, prefixPath=None):
525536
super(ClangBuilder, self).__init__(cmd, isCxx, prefixPath)
@@ -537,11 +548,6 @@ def getCompiler(self):
537548
def getBitcodeArglistFilter(self):
538549
return ClangBitcodeArgumentListFilter(self.cmd)
539550

540-
def getBitcodeFileName(self, argFilter):
541-
(dirs, baseFile) = os.path.split(argFilter.getOutputFilename())
542-
bcfilename = os.path.join(dirs, '.{0}.bc'.format(baseFile))
543-
return bcfilename
544-
545551
def extraBitcodeArgs(self, argFilter):
546552
bcPath = self.getBitcodeFileName(argFilter)
547553
return ['-o', bcPath]
@@ -562,8 +568,10 @@ def getBitcodeCompiler(self):
562568
# We use '-B' to tell gcc where to look for an assembler.
563569
# When we build LLVM bitcode we do not want to use the GNU assembler,
564570
# instead we want gcc to use our own assembler (see driver/as).
565-
return cc + ['-B', driverDir, '-fplugin={0}'.format(pth),
566-
'-fplugin-arg-dragonegg-emit-ir']
571+
cmd = cc + ['-B', driverDir, '-fplugin={0}'.format(pth), '-fplugin-arg-dragonegg-emit-ir']
572+
if DEBUG:
573+
print(cmd)
574+
return cmd
567575

568576
def getCompiler(self):
569577
pfx = ''
@@ -575,6 +583,7 @@ def getCompiler(self):
575583
else:
576584
return ['{0}{1}gcc'.format(self.prefixPath, pfx)]
577585

586+
578587
def getBitcodeArglistFilter(self):
579588
return ArgumentListFilter(self.cmd)
580589

@@ -687,6 +696,8 @@ def buildBitcodeFile(builder, srcFile, bcFile):
687696
bcc.extend(af.compileArgs)
688697
bcc.extend(['-c', srcFile])
689698
bcc.extend(['-o', bcFile])
699+
if DEBUG:
700+
print('buildBitcodeFile: {0}\n'.format(bcc))
690701
proc = Popen(bcc)
691702
rc = proc.wait()
692703
if rc != 0:
@@ -699,6 +710,8 @@ def buildObjectFile(builder, srcFile, objFile):
699710
cc.extend(af.compileArgs)
700711
cc.append(srcFile)
701712
cc.extend(['-c', '-o', objFile])
713+
if DEBUG:
714+
print('buildObjectFile: {0}\n'.format(cc))
702715
proc = Popen(cc)
703716
rc = proc.wait()
704717
if rc != 0:

test/test_files/Makefile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#iam: please leave this Makefile; it is useful for debugging when things break.
2+
3+
zero:
4+
${CXX} hello.cc -o hello
5+
6+
one:
7+
${CC} foo.c bar.c baz.c main.c -o main
8+
9+
two:
10+
${CC} foo.c bar.c baz.c main.c -c
11+
${CC} foo.o bar.o baz.o main.o -o main
12+
13+
mix:
14+
${CC} foo.c bar.c -c
15+
${CC} foo.o bar.o baz.c main.c -o main
16+
17+
objects:
18+
${CC} foo.c -c
19+
${CC} bar.c -c
20+
${CC} baz.c -c
21+
${CC} main.c -c
22+
23+
many: objects
24+
${CC} foo.o bar.o baz.o main.o -o main
25+
26+
archive: objects
27+
ar cr libfoo.a foo.o bar.o baz.o
28+
ranlib libfoo.a
29+
30+
dylib: objects
31+
${CC} -dynamiclib foo.o bar.o baz.o -o libfoo.dylib
32+
33+
deadstrip: objects
34+
${CC} -dynamiclib -Wl,-dead_strip foo.o bar.o baz.o -o libfoo.dylib
35+
36+
link_with_archive:: archive
37+
$(CC) main.o libfoo.a -o main.arch
38+
39+
clean:
40+
rm -f *.o main main.arch .*.o.bc .*.o *.bc .*.bc a.out *.s *.i hello *.a *.bca *.dylib
41+
42+
mystery:
43+
otool -X -s __LLVM __llvm_bc main > main.otool
44+
xxd -r main.otool
45+
xxd -r main.otool main.xxd

0 commit comments

Comments
 (0)