remove Go -no-cgo option
It only worked for Go versions before 1.5, which is more than five years ago and long-unsupported.
This commit is contained in:
parent
6e471512b8
commit
4461c443cf
3 changed files with 167 additions and 1761 deletions
|
|
@ -71,6 +71,7 @@ code. SWIG fills this gap.
|
|||
There are (at least) two different Go compilers. The first is the gc compiler
|
||||
of the <a href="https://golang.org/doc/install">Go distribution</a>, normally
|
||||
invoked via the <a href="https://golang.org/cmd/go/">go tool</a>.
|
||||
SWIG supports the gc compiler version 1.2 or later.
|
||||
The second Go compiler is the <a href="https://golang.org/doc/install/gccgo">
|
||||
gccgo compiler</a>, which is a frontend to the GCC compiler suite.
|
||||
The interface to C/C++ code is completely different for the two Go compilers.
|
||||
|
|
@ -142,44 +143,6 @@ You will now have a Go package that you can import from other Go packages as
|
|||
usual.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
SWIG can be used without cgo, via the <tt>-no-cgo</tt> option, but
|
||||
more steps are required. This only works with Go versions before 1.5.
|
||||
When using Go version 1.2 or later, or when using gccgo, the code
|
||||
generated by SWIG can be linked directly into the Go program. A
|
||||
typical command sequence when using the Go compiler of the Go
|
||||
distribution would look like this:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
% swig -go -no-cgo example.i
|
||||
% gcc -c code.c # The C library being wrapped.
|
||||
% gcc -c example_wrap.c
|
||||
% go tool 6g example.go
|
||||
% go tool 6c example_gc.c
|
||||
% go tool pack grc example.a example.6 example_gc.6 code.o example_wrap.o
|
||||
% go tool 6g main.go
|
||||
% go tool 6l main.6
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
You can also put the wrapped code into a shared library, and when using the Go
|
||||
versions before 1.2 this is the only supported option. A typical command
|
||||
sequence for this approach would look like this:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
% swig -go -no-cgo -use-shlib example.i
|
||||
% gcc -c -fpic example.c
|
||||
% gcc -c -fpic example_wrap.c
|
||||
% gcc -shared example.o example_wrap.o -o example.so
|
||||
% go tool 6g example.go
|
||||
% go tool 6c example_gc.c
|
||||
% go tool pack grc example.a example.6 example_gc.6
|
||||
% go tool 6g main.go # your code, not generated by SWIG
|
||||
% go tool 6l main.6
|
||||
</pre></div>
|
||||
|
||||
|
||||
<H3><a name="Go_commandline">25.3.1 Go-specific Commandline Options</a></H3>
|
||||
|
||||
|
|
@ -206,9 +169,7 @@ swig -go -help
|
|||
|
||||
<tr>
|
||||
<td>-no-cgo</td>
|
||||
<td>Generate files that can be used directly, rather than via the Go
|
||||
cgo tool. This option does not work with Go 1.5 or later. It is
|
||||
required for versions of Go before 1.2.</td>
|
||||
<td>This option is no longer supported.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
|
@ -279,13 +240,10 @@ swig -go -help
|
|||
<H3><a name="Go_outputs">25.3.2 Generated Wrapper Files</a></H3>
|
||||
|
||||
|
||||
<p>There are two different approaches to generating wrapper files,
|
||||
controlled by SWIG's <tt>-no-cgo</tt> option. The <tt>-no-cgo</tt>
|
||||
option only works with version of Go before 1.5. It is required
|
||||
when using versions of Go before 1.2.</p>
|
||||
|
||||
<p>With or without the <tt>-no-cgo</tt> option, SWIG will generate the
|
||||
following files when generating wrapper code:</p>
|
||||
<p>
|
||||
SWIG will generate the following files when generating wrapper
|
||||
code:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
|
|
@ -308,17 +266,6 @@ or C++ compiler.
|
|||
</li>
|
||||
</ul>
|
||||
|
||||
<p>When the <tt>-no-cgo</tt> option is used, and the <tt>-gccgo</tt>
|
||||
option is not used, SWIG will also generate an additional file:</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
MODULE_gc.c will contain C code which should be compiled with the C
|
||||
compiler distributed as part of the gc compiler. It should then be
|
||||
combined with the compiled MODULE.go using go tool pack.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<H2><a name="Go_basic_tour">25.4 A tour of basic C/C++ wrapping</a></H2>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue