[llvm] e8f8873 - Rework go bindings so that validation works fine

via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 13 05:15:54 PST 2020


Author: serge-sans-paille
Date: 2020-02-13T14:13:03+01:00
New Revision: e8f8873da5eaad187f82dad78ebdb3ab3df22b36

URL: https://github.com/llvm/llvm-project/commit/e8f8873da5eaad187f82dad78ebdb3ab3df22b36
DIFF: https://github.com/llvm/llvm-project/commit/e8f8873da5eaad187f82dad78ebdb3ab3df22b36.diff

LOG: Rework go bindings so that validation works fine

Basically change the layout to please `go build` and remove references to
`llvm-go`.

Update llvm/test/Bindings/Go/ to use the system go compiler

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

Added: 
    llvm/bindings/go/src/llvm/IRBindings.cpp
    llvm/bindings/go/src/llvm/IRBindings.h
    llvm/bindings/go/src/llvm/InstrumentationBindings.cpp
    llvm/bindings/go/src/llvm/InstrumentationBindings.h
    llvm/bindings/go/src/llvm/SupportBindings.cpp
    llvm/bindings/go/src/llvm/SupportBindings.h
    llvm/bindings/go/src/llvm/analysis.go
    llvm/bindings/go/src/llvm/bitreader.go
    llvm/bindings/go/src/llvm/bitwriter.go
    llvm/bindings/go/src/llvm/dibuilder.go
    llvm/bindings/go/src/llvm/executionengine.go
    llvm/bindings/go/src/llvm/executionengine_test.go
    llvm/bindings/go/src/llvm/ir.go
    llvm/bindings/go/src/llvm/ir_test.go
    llvm/bindings/go/src/llvm/linker.go
    llvm/bindings/go/src/llvm/llvm_config.go.in
    llvm/bindings/go/src/llvm/llvm_dep.go
    llvm/bindings/go/src/llvm/string.go
    llvm/bindings/go/src/llvm/string_test.go
    llvm/bindings/go/src/llvm/support.go
    llvm/bindings/go/src/llvm/target.go
    llvm/bindings/go/src/llvm/transforms_coroutines.go
    llvm/bindings/go/src/llvm/transforms_instrumentation.go
    llvm/bindings/go/src/llvm/transforms_ipo.go
    llvm/bindings/go/src/llvm/transforms_pmbuilder.go
    llvm/bindings/go/src/llvm/transforms_scalar.go
    llvm/bindings/go/src/llvm/version.go

Modified: 
    llvm/test/Bindings/Go/go.test
    llvm/test/Bindings/Go/lit.local.cfg
    llvm/test/lit.cfg.py
    llvm/utils/lit/lit/llvm/subst.py

Removed: 
    llvm/bindings/go/build.sh
    llvm/bindings/go/llvm/IRBindings.cpp
    llvm/bindings/go/llvm/IRBindings.h
    llvm/bindings/go/llvm/InstrumentationBindings.cpp
    llvm/bindings/go/llvm/InstrumentationBindings.h
    llvm/bindings/go/llvm/SupportBindings.cpp
    llvm/bindings/go/llvm/SupportBindings.h
    llvm/bindings/go/llvm/analysis.go
    llvm/bindings/go/llvm/bitreader.go
    llvm/bindings/go/llvm/bitwriter.go
    llvm/bindings/go/llvm/dibuilder.go
    llvm/bindings/go/llvm/executionengine.go
    llvm/bindings/go/llvm/executionengine_test.go
    llvm/bindings/go/llvm/ir.go
    llvm/bindings/go/llvm/ir_test.go
    llvm/bindings/go/llvm/linker.go
    llvm/bindings/go/llvm/llvm_config.go.in
    llvm/bindings/go/llvm/llvm_dep.go
    llvm/bindings/go/llvm/string.go
    llvm/bindings/go/llvm/string_test.go
    llvm/bindings/go/llvm/support.go
    llvm/bindings/go/llvm/target.go
    llvm/bindings/go/llvm/transforms_coroutines.go
    llvm/bindings/go/llvm/transforms_instrumentation.go
    llvm/bindings/go/llvm/transforms_ipo.go
    llvm/bindings/go/llvm/transforms_pmbuilder.go
    llvm/bindings/go/llvm/transforms_scalar.go
    llvm/bindings/go/llvm/version.go


################################################################################
diff  --git a/llvm/bindings/go/build.sh b/llvm/bindings/go/build.sh
deleted file mode 100755
index 3177852aebad..000000000000
--- a/llvm/bindings/go/build.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh -xe
-
-gollvmdir=$(dirname "$0")/llvm
-
-workdir=$gollvmdir/workdir
-llvmdir=$gollvmdir/../../..
-llvm_builddir=$workdir/llvm_build
-
-mkdir -p $llvm_builddir
-
-cmake_flags="../../../../.. $@"
-llvm_config="$llvm_builddir/bin/llvm-config"
-llvm_go="$llvm_builddir/bin/llvm-go"
-
-if test -n "`which ninja`" ; then
-  # If Ninja is available, we can speed up the build by building only the
-  # required subset of LLVM.
-  (cd $llvm_builddir && cmake -G Ninja $cmake_flags)
-  ninja -C $llvm_builddir llvm-config llvm-go
-  llvm_components="$($llvm_go print-components)"
-  llvm_buildtargets="$($llvm_config --libs $llvm_components | sed -e 's/-l//g')"
-  ninja -C $llvm_builddir $llvm_buildtargets FileCheck
-else
-  (cd $llvm_builddir && cmake $cmake_flags)
-  make -C $llvm_builddir -j4
-fi
-
-$llvm_go print-config > $gollvmdir/llvm_config.go

diff  --git a/llvm/bindings/go/llvm/IRBindings.cpp b/llvm/bindings/go/src/llvm/IRBindings.cpp
similarity index 100%
rename from llvm/bindings/go/llvm/IRBindings.cpp
rename to llvm/bindings/go/src/llvm/IRBindings.cpp

diff  --git a/llvm/bindings/go/llvm/IRBindings.h b/llvm/bindings/go/src/llvm/IRBindings.h
similarity index 100%
rename from llvm/bindings/go/llvm/IRBindings.h
rename to llvm/bindings/go/src/llvm/IRBindings.h

diff  --git a/llvm/bindings/go/llvm/InstrumentationBindings.cpp b/llvm/bindings/go/src/llvm/InstrumentationBindings.cpp
similarity index 100%
rename from llvm/bindings/go/llvm/InstrumentationBindings.cpp
rename to llvm/bindings/go/src/llvm/InstrumentationBindings.cpp

diff  --git a/llvm/bindings/go/llvm/InstrumentationBindings.h b/llvm/bindings/go/src/llvm/InstrumentationBindings.h
similarity index 100%
rename from llvm/bindings/go/llvm/InstrumentationBindings.h
rename to llvm/bindings/go/src/llvm/InstrumentationBindings.h

diff  --git a/llvm/bindings/go/llvm/SupportBindings.cpp b/llvm/bindings/go/src/llvm/SupportBindings.cpp
similarity index 100%
rename from llvm/bindings/go/llvm/SupportBindings.cpp
rename to llvm/bindings/go/src/llvm/SupportBindings.cpp

diff  --git a/llvm/bindings/go/llvm/SupportBindings.h b/llvm/bindings/go/src/llvm/SupportBindings.h
similarity index 100%
rename from llvm/bindings/go/llvm/SupportBindings.h
rename to llvm/bindings/go/src/llvm/SupportBindings.h

diff  --git a/llvm/bindings/go/llvm/analysis.go b/llvm/bindings/go/src/llvm/analysis.go
similarity index 100%
rename from llvm/bindings/go/llvm/analysis.go
rename to llvm/bindings/go/src/llvm/analysis.go

diff  --git a/llvm/bindings/go/llvm/bitreader.go b/llvm/bindings/go/src/llvm/bitreader.go
similarity index 100%
rename from llvm/bindings/go/llvm/bitreader.go
rename to llvm/bindings/go/src/llvm/bitreader.go

diff  --git a/llvm/bindings/go/llvm/bitwriter.go b/llvm/bindings/go/src/llvm/bitwriter.go
similarity index 100%
rename from llvm/bindings/go/llvm/bitwriter.go
rename to llvm/bindings/go/src/llvm/bitwriter.go

diff  --git a/llvm/bindings/go/llvm/dibuilder.go b/llvm/bindings/go/src/llvm/dibuilder.go
similarity index 100%
rename from llvm/bindings/go/llvm/dibuilder.go
rename to llvm/bindings/go/src/llvm/dibuilder.go

diff  --git a/llvm/bindings/go/llvm/executionengine.go b/llvm/bindings/go/src/llvm/executionengine.go
similarity index 100%
rename from llvm/bindings/go/llvm/executionengine.go
rename to llvm/bindings/go/src/llvm/executionengine.go

diff  --git a/llvm/bindings/go/llvm/executionengine_test.go b/llvm/bindings/go/src/llvm/executionengine_test.go
similarity index 100%
rename from llvm/bindings/go/llvm/executionengine_test.go
rename to llvm/bindings/go/src/llvm/executionengine_test.go

diff  --git a/llvm/bindings/go/llvm/ir.go b/llvm/bindings/go/src/llvm/ir.go
similarity index 100%
rename from llvm/bindings/go/llvm/ir.go
rename to llvm/bindings/go/src/llvm/ir.go

diff  --git a/llvm/bindings/go/llvm/ir_test.go b/llvm/bindings/go/src/llvm/ir_test.go
similarity index 100%
rename from llvm/bindings/go/llvm/ir_test.go
rename to llvm/bindings/go/src/llvm/ir_test.go

diff  --git a/llvm/bindings/go/llvm/linker.go b/llvm/bindings/go/src/llvm/linker.go
similarity index 100%
rename from llvm/bindings/go/llvm/linker.go
rename to llvm/bindings/go/src/llvm/linker.go

diff  --git a/llvm/bindings/go/llvm/llvm_config.go.in b/llvm/bindings/go/src/llvm/llvm_config.go.in
similarity index 100%
rename from llvm/bindings/go/llvm/llvm_config.go.in
rename to llvm/bindings/go/src/llvm/llvm_config.go.in

diff  --git a/llvm/bindings/go/llvm/llvm_dep.go b/llvm/bindings/go/src/llvm/llvm_dep.go
similarity index 96%
rename from llvm/bindings/go/llvm/llvm_dep.go
rename to llvm/bindings/go/src/llvm/llvm_dep.go
index 9484e6ddf879..e3ccce00b713 100644
--- a/llvm/bindings/go/llvm/llvm_dep.go
+++ b/llvm/bindings/go/src/llvm/llvm_dep.go
@@ -14,5 +14,3 @@
 // +build !byollvm
 
 package llvm
-
-var _ run_build_sh

diff  --git a/llvm/bindings/go/llvm/string.go b/llvm/bindings/go/src/llvm/string.go
similarity index 100%
rename from llvm/bindings/go/llvm/string.go
rename to llvm/bindings/go/src/llvm/string.go

diff  --git a/llvm/bindings/go/llvm/string_test.go b/llvm/bindings/go/src/llvm/string_test.go
similarity index 100%
rename from llvm/bindings/go/llvm/string_test.go
rename to llvm/bindings/go/src/llvm/string_test.go

diff  --git a/llvm/bindings/go/llvm/support.go b/llvm/bindings/go/src/llvm/support.go
similarity index 100%
rename from llvm/bindings/go/llvm/support.go
rename to llvm/bindings/go/src/llvm/support.go

diff  --git a/llvm/bindings/go/llvm/target.go b/llvm/bindings/go/src/llvm/target.go
similarity index 100%
rename from llvm/bindings/go/llvm/target.go
rename to llvm/bindings/go/src/llvm/target.go

diff  --git a/llvm/bindings/go/llvm/transforms_coroutines.go b/llvm/bindings/go/src/llvm/transforms_coroutines.go
similarity index 100%
rename from llvm/bindings/go/llvm/transforms_coroutines.go
rename to llvm/bindings/go/src/llvm/transforms_coroutines.go

diff  --git a/llvm/bindings/go/llvm/transforms_instrumentation.go b/llvm/bindings/go/src/llvm/transforms_instrumentation.go
similarity index 100%
rename from llvm/bindings/go/llvm/transforms_instrumentation.go
rename to llvm/bindings/go/src/llvm/transforms_instrumentation.go

diff  --git a/llvm/bindings/go/llvm/transforms_ipo.go b/llvm/bindings/go/src/llvm/transforms_ipo.go
similarity index 100%
rename from llvm/bindings/go/llvm/transforms_ipo.go
rename to llvm/bindings/go/src/llvm/transforms_ipo.go

diff  --git a/llvm/bindings/go/llvm/transforms_pmbuilder.go b/llvm/bindings/go/src/llvm/transforms_pmbuilder.go
similarity index 100%
rename from llvm/bindings/go/llvm/transforms_pmbuilder.go
rename to llvm/bindings/go/src/llvm/transforms_pmbuilder.go

diff  --git a/llvm/bindings/go/llvm/transforms_scalar.go b/llvm/bindings/go/src/llvm/transforms_scalar.go
similarity index 100%
rename from llvm/bindings/go/llvm/transforms_scalar.go
rename to llvm/bindings/go/src/llvm/transforms_scalar.go

diff  --git a/llvm/bindings/go/llvm/version.go b/llvm/bindings/go/src/llvm/version.go
similarity index 100%
rename from llvm/bindings/go/llvm/version.go
rename to llvm/bindings/go/src/llvm/version.go

diff  --git a/llvm/test/Bindings/Go/go.test b/llvm/test/Bindings/Go/go.test
index bb39e6c8455c..5901ccbf6ae8 100644
--- a/llvm/test/Bindings/Go/go.test
+++ b/llvm/test/Bindings/Go/go.test
@@ -1,4 +1,4 @@
-; RUN: llvm-go test llvm.org/llvm/bindings/go/llvm
+; RUN: CGO_CPPFLAGS="`llvm-config --cppflags`" CGO_CXXFLAGS=-std=c++14 CGO_LDFLAGS="`llvm-config --ldflags --libs --system-libs all`" go test llvm
 
 ; REQUIRES: shell
 ; UNSUPPORTED: asan, ubsan, msan

diff  --git a/llvm/test/Bindings/Go/lit.local.cfg b/llvm/test/Bindings/Go/lit.local.cfg
index 3021fc64a750..7c72c7687e61 100644
--- a/llvm/test/Bindings/Go/lit.local.cfg
+++ b/llvm/test/Bindings/Go/lit.local.cfg
@@ -57,4 +57,5 @@ def fixup_compiler_path(compiler):
 
 config.environment['CC'] = fixup_compiler_path(config.host_cc)
 config.environment['CXX'] = fixup_compiler_path(config.host_cxx)
-config.environment['CGO_LDFLAGS'] = config.host_ldflags
+config.environment['LD_LIBRARY_PATH'] = config.llvm_shlib_dir
+config.environment['GOPATH'] = os.path.join(config.llvm_src_root, 'bindings', 'go')

diff  --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index 777322e0c2ad..5789f9d6ade5 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -160,7 +160,7 @@ def get_asan_rtlib():
 
 # The following tools are optional
 tools.extend([
-    ToolSubst('llvm-go', unresolved='ignore'),
+    ToolSubst('go', unresolved='ignore'),
     ToolSubst('llvm-mt', unresolved='ignore'),
     ToolSubst('Kaleidoscope-Ch3', unresolved='ignore'),
     ToolSubst('Kaleidoscope-Ch4', unresolved='ignore'),

diff  --git a/llvm/utils/lit/lit/llvm/subst.py b/llvm/utils/lit/lit/llvm/subst.py
index 4275b8a56a3b..c4a269262f75 100644
--- a/llvm/utils/lit/lit/llvm/subst.py
+++ b/llvm/utils/lit/lit/llvm/subst.py
@@ -23,7 +23,7 @@ def resolve(self, config, dirs):
 
         if self.name == 'llc' and os.environ.get('LLVM_ENABLE_MACHINE_VERIFIER') == '1':
             command += ' -verify-machineinstrs'
-        elif self.name == 'llvm-go':
+        elif self.name == 'go':
             exe = getattr(config.config, 'go_executable', None)
             if exe:
                 command += ' go=' + exe


        


More information about the llvm-commits mailing list