[llvm-commits] [hlvm] r38142 - in /hlvm/trunk: build/bytecode.py build/configure.py build/hlvm.py hlvm/Runtime/FileIO.cpp hlvm/Runtime/FileIO.h hlvm/Runtime/SConscript hlvm/Runtime/String.cpp test/lib/return0.exp tools/hlvm/SConscript

Reid Spencer reid at x10sys.com
Sat Jul 7 17:00:20 PDT 2007


Author: reid
Date: Sat Jul  7 19:00:20 2007
New Revision: 38142

URL: http://llvm.org/viewvc/llvm-project?rev=38142&view=rev
Log:
Get the return0 test program to link to a native executable. Unfortunately,
it seg faults in the stdc++ library on a sentry. Not sure what that is about
but probably has to do with calling initializers or some such.  The main
reason for this commit is to add the bytecode builders to the SConscript files
and get bytecode (.bc) and bytecode archive (.bca) generation working.

Modified:
    hlvm/trunk/build/bytecode.py
    hlvm/trunk/build/configure.py
    hlvm/trunk/build/hlvm.py
    hlvm/trunk/hlvm/Runtime/FileIO.cpp
    hlvm/trunk/hlvm/Runtime/FileIO.h
    hlvm/trunk/hlvm/Runtime/SConscript
    hlvm/trunk/hlvm/Runtime/String.cpp
    hlvm/trunk/test/lib/return0.exp
    hlvm/trunk/tools/hlvm/SConscript

Modified: hlvm/trunk/build/bytecode.py
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/build/bytecode.py?rev=38142&r1=38141&r2=38142&view=diff

==============================================================================
--- hlvm/trunk/build/bytecode.py (original)
+++ hlvm/trunk/build/bytecode.py Sat Jul  7 19:00:20 2007
@@ -3,24 +3,47 @@
 from string import join as sjoin
 from os.path import join as pjoin
 
+def BytecodeMessage(target,source,env):
+  return "Generating Bytecode From C++ Source"
+
 def BytecodeAction(target,source,env):
-  funcName = os.path.splitext(os.path.basename(source[0].path))[0]
-  sources = ""
-  for src in source:
-    sources += " " + src.path
+  includes = ""
+  for inc in env['CPPPATH']:
+    if inc[0] == '#':
+      inc = env['AbsSrcRoot'] + inc[1:]
+    includes += " -I" + inc
+  defines = ""
+  for d in env['CPPDEFINES'].keys():
+    if env['CPPDEFINES'][d] == None:
+      defines += " -D" + d
+    else:
+      defines += " -D" + d + "=" + env['CPPDEFINES'][d]
+  src = source[0].path
   tgt = target[0].path
   theAction = env.Action(
-    "PATH='" + env['LLVM_bin'] + "' " + env['with_llvmgxx'] + 
-      " -c -x c++ " + sources + " -o " + tgt)
+    "PATH='" + env['LLVM_bin'] + "' " + env['with_llvmgxx'] + ' -Wall' +
+      includes + defines + " -c -x c++ " + src + " -o " + tgt )
   env.Depends(target,env['with_llvmgxx'])
-  env.Execute(theAction);
-  return 0
+  return env.Execute(theAction);
+
+def BytecodeArchiveMessage(target,source,env):
+  return "Generating Bytecode Archive From Bytecode Modules"
+
+def BytecodeArchiveAction(target,source,env):
+  sources = ''
+  for src in source:
+    sources += ' ' + src.path
+  theAction = env.Action(
+    env['with_llvmar'] + ' cr ' + target[0].path + sources)
+  env.Depends(target[0],env['with_llvmar'])
+  return env.Execute(theAction);
 
-def BytecodeMessage(target,source,env):
-  return "Generating Bytecode From C++ Source"
 
 def Bytecode(env):
-  a = env.Action(BytecodeAction,BytecodeMessage)
-  b = env.Builder(action=a,suffix='bc',src_suffix='cpp')
-  env.Append(BUILDERS = {'Bytecode':b})
+  bc = env.Action(BytecodeAction,BytecodeMessage)
+  arch = env.Action(BytecodeArchiveAction,BytecodeArchiveMessage)
+  bc_bldr = env.Builder(action=bc,suffix='bc',src_suffix='cpp',single_source=1)
+  arch_bldr = env.Builder(
+    action=arch,suffix='bca',src_suffix='bc',src_builder=bc_bldr)
+  env.Append(BUILDERS = {'Bytecode':bc_bldr, 'BytecodeArchive':arch_bldr})
   return 1

Modified: hlvm/trunk/build/configure.py
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/build/configure.py?rev=38142&r1=38141&r2=38142&view=diff

==============================================================================
--- hlvm/trunk/build/configure.py (original)
+++ hlvm/trunk/build/configure.py Sat Jul  7 19:00:20 2007
@@ -282,6 +282,8 @@
     _failed(env)
   if not conf.CheckProgram('llvm2cpp','with_llvm2cpp',[env['LLVM_bin']]):
     _failed(env)
+  if not conf.CheckProgram('llvm-ar','with_llvmar',[env['LLVM_bin']]):
+    _failed(env)
   if not conf.CheckProgram('runtest','with_runtest'):
     env['with_runtest'] = None
     print "*** TESTING DISABLED ***"

Modified: hlvm/trunk/build/hlvm.py
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/build/hlvm.py?rev=38142&r1=38141&r2=38142&view=diff

==============================================================================
--- hlvm/trunk/build/hlvm.py (original)
+++ hlvm/trunk/build/hlvm.py Sat Jul  7 19:00:20 2007
@@ -102,6 +102,8 @@
            '/usr/local/bin/llvm-gcc')
   opts.Add('with_llvmgxx','Specify where the LLVM C++ compiler is located',
            '/usr/local/bin/llvm-g++')
+  opts.Add('with_llvmar','Specify where the LLVM bytecode archiver is located',
+           '/usr/local/bin/llvm-g++')
   opts.Add('with_llvm2cpp','Specify where the LLVM llvm2cpp program is located',
            '/usr/local/bin/llvm2cpp')
   opts.Add('with_runtest','Specify where DejaGnu runtest program is located',

Modified: hlvm/trunk/hlvm/Runtime/FileIO.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Runtime/FileIO.cpp?rev=38142&r1=38141&r2=38142&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Runtime/FileIO.cpp (original)
+++ hlvm/trunk/hlvm/Runtime/FileIO.cpp Sat Jul  7 19:00:20 2007
@@ -38,7 +38,7 @@
 {
 
 void* 
-_hlvm_op_file_open(_hlvm_ty_string* fname, uint32_t flags)
+_hlvm_op_file_open(_hlvm_ty_string* uri)
 {
   return 0;
 }

Modified: hlvm/trunk/hlvm/Runtime/FileIO.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Runtime/FileIO.h?rev=38142&r1=38141&r2=38142&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Runtime/FileIO.h (original)
+++ hlvm/trunk/hlvm/Runtime/FileIO.h Sat Jul  7 19:00:20 2007
@@ -31,16 +31,15 @@
 #define HLVM_RUNTIME_FILEIO_H
 
 #include <hlvm/Runtime/String.h>
-#include <llvm/Support/DataTypes.h>
 
 extern "C" 
 {
 
-void* _hlvm_op_file_open(_hlvm_ty_string* fname, uint32_t flags);
-
-void _hlvm_op_file_close(void* file);
+void* _hlvm_op_file_open(_hlvm_ty_string* uri);
 
 uint32_t _hovm_op_file_write(void* file, void* data, size_t len);
+
+void _hlvm_op_file_close(void* file);
 }
 
 #endif

Modified: hlvm/trunk/hlvm/Runtime/SConscript
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Runtime/SConscript?rev=38142&r1=38141&r2=38142&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Runtime/SConscript (original)
+++ hlvm/trunk/hlvm/Runtime/SConscript Sat Jul  7 19:00:20 2007
@@ -20,8 +20,10 @@
 # MA 02110-1301 USA
 #
 #===----------------------------------------------------------------------===#
-from build import hlvm
 Import('env')
+from build import hlvm
+hlvm.GetBytecode(env)
+env.BytecodeArchive('HLVMRuntime.bca',hlvm.GetAllCXXFiles(env))
 lib = env.SharedLibrary('HLVMRuntime',hlvm.GetAllCXXFiles(env))
 hlvm.InstallLibrary(env,lib)
 hlvm.InstallHeader(env,hlvm.GetFiles(env,'*.h'))

Modified: hlvm/trunk/hlvm/Runtime/String.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Runtime/String.cpp?rev=38142&r1=38141&r2=38142&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Runtime/String.cpp (original)
+++ hlvm/trunk/hlvm/Runtime/String.cpp Sat Jul  7 19:00:20 2007
@@ -30,9 +30,6 @@
 #include <hlvm/Runtime/String.h>
 #include <apr-1/apr_strings.h>
 
-namespace {
-}
-
 extern "C" {
 
 }

Modified: hlvm/trunk/test/lib/return0.exp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/lib/return0.exp?rev=38142&r1=38141&r2=38142&view=diff

==============================================================================
--- hlvm/trunk/test/lib/return0.exp (original)
+++ hlvm/trunk/test/lib/return0.exp Sat Jul  7 19:00:20 2007
@@ -25,6 +25,9 @@
   set outdir [file join $objdir $subdir]
   set compiler [file join $objrootdir tools hlvm-compiler hlvm-compiler ]
   set source [file join $srcdir $subdir ]
+  set rtlib [file join $objrootdir hlvm Runtime HLVMRuntime.bca ]
+  set vmlib [file join $objrootdir tools hlvm hlvm.bca ]
+  set vmmain [file join $objrootdir tools hlvm hlvm.bc ]
   set files [lsort [
     glob -nocomplain -tails -types {f r} -directory $source $pat]]
   set dirs [lsort [
@@ -44,18 +47,24 @@
   foreach test $files {
     set output [file join $outdir ${test}.out]
     set testsrc [file join $source $test]
-    set testexe [file rootname $test]
+    set testexe [file join $outdir [file rootname $test] ]
+    set testbc  [file join $outdir ${test}.bc ]
     set execout ""
-    set retval [ catch { exec -keepnewline $compiler $testsrc -llvmbc -o - | $llcpath -f -march x86 -o $testexe } msg ]
+    set retval [ catch { exec -keepnewline $compiler $testsrc -llvmbc -o $testbc } msg ] 
     if { $retval != 0 } {
       fail "$test: hlvm-compiler returned $retval:\n$msg"
     } else {
+      set retval [ catch { exec -keepnewline gccld -native -o $testexe $vmmain $vmlib $rtlib $testbc -L/proj/llvm/cfrontend/install/lib -L/proj/install/lib -L/proj/hlvm/hlvm/build.spADio/hlvm/Base -lHLVMBase -lLLVMSupport -lLLVMbzip2 -LLLVMSystem -lapr-1 -laprutil-1 -lstdc++ -lgcc -lc } msg ]
       # Run the program compiled and see if it returns 0
-      set retval [ catch {exec $testexe } msg ]
-      if {$retval == 1} {
-        fail "$test: $testexe returned $retval:\n$msg"
+      if { $retval != 0 } {
+        fail "$test: gccld returned $retval:\n$msg"
       } else {
-        pass "$test"
+        set retval [ catch {exec $testexe } msg ]
+        if {$retval == 1} {
+          fail "$test: $testexe returned $retval:\n$msg"
+        } else {
+          pass "$test"
+        }
       }
     }
   }

Modified: hlvm/trunk/tools/hlvm/SConscript
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/tools/hlvm/SConscript?rev=38142&r1=38141&r2=38142&view=diff

==============================================================================
--- hlvm/trunk/tools/hlvm/SConscript (original)
+++ hlvm/trunk/tools/hlvm/SConscript Sat Jul  7 19:00:20 2007
@@ -22,6 +22,8 @@
 #===----------------------------------------------------------------------===#
 from build import hlvm
 Import('env')
+hlvm.GetBytecode(env)
+env.BytecodeArchive('hlvm.bca',hlvm.GetAllCXXFiles(env))
 env.Program('hlvm', hlvm.GetAllCXXFiles(env),
   LIBS=[
     'HLVMXMLReader',





More information about the llvm-commits mailing list