README.rst
1.. _#2067: https://github.com/bazelbuild/rules_go/issues/2067
2.. _#2622: https://github.com/bazelbuild/rules_go/issues/2622
3
4Basic cgo functionality
5=======================
6
7opts_test
8---------
9
10Checks that different sets of options are passed to C and C++ sources in a
11``go_library`` with ``cgo = True``.
12
13(generated_)?(versioned_)?dylib_test
14------------------------------------
15
16Checks that Go binaries can link against dynamic C libraries. Some libraries
17(especially those provided with ``cc_import``) may only have dynamic versions,
18and we should be able to link against them and find them at run-time.
19
20The non ``generated_`` tests are manual. The ``generate_imported_dylib.sh``
21script must be run before running the tests themselves.
22
23The ``generated_`` variants check that Go binaries can link against dynamic C
24libraries that are generated by another rule, rather than being included in the
25source tree.
26
27The ``versioned_`` variants check that Go binaries can link against dynamic C
28libraries that are only available as a versioned shared library, like
29``libfoo.so.1``, as used on Linux.
30
31cc_libs_test
32------------
33
34Checks that Go binaries that include cgo code may or may not link against
35libstdc++, depending on how they're linked. This tests several binaries:
36
37* ``pure_bin`` - built in ``"pure"`` mode, should not depend on libstdc++.
38* ``c_srcs`` - has no C++ code in sources, should not depend on libstdc++.
39* ``cc_srcs`` - has some C++ code in sources, should depend on libstdc++.
40* ``cc_deps`` - depends on a ``cc_library``, should depend on libstdc++
41 because we don't know what's in it.
42
43race_test
44---------
45
46Checks that cgo code in a binary with ``race = "on"`` is compiled in race mode.
47Verifies #1592.
48
49tag_test
50--------
51
52Checks that sources with ``// +build cgo`` are built when cgo is enabled
53(whether or not ``cgo = True`` is set), and sources with ``// +build !cgo``
54are only built in pure mode.
55
56cdeps_link_test
57---------------
58
59Checks that libraries in ``cdeps`` are linked into the generated ``_cgo_.o``
60executable used to produce ``_cgo_imports.go``. Verifies `#2067`_.
61
62split_import_test
63-----------------
64
65Checks that when a package with ``cdeps`` is recompiled due to a split test,
66the input files from ``cdeps`` are included in the recompilation and are passed
67to the linker. Verifies `#2622`_.
68