File tree Expand file tree Collapse file tree 13 files changed +31
-26
lines changed Expand file tree Collapse file tree 13 files changed +31
-26
lines changed Original file line number Diff line number Diff line change 1111 [config_setting]: https://docs.bazel.build/versions/master/be/general.html#config_setting
1212 [data dependencies]: https://bazel.build/concepts/dependencies#data-dependencies
1313 [goarch]: /go/modes.rst#goarch
14- [gofips140]: /go/modes.rst#gofips140
1514 [goos]: /go/modes.rst#goos
1615 [mode attributes]: /go/modes.rst#mode-attributes
1716 [nogo]: /go/nogo.rst#nogo
@@ -59,7 +58,6 @@ sufficient to match the capabilities of the normal go tools.
5958- [config_setting]
6059- [data dependencies]
6160- [goarch]
62- - [gofips140]
6361- [goos]
6462- [mode attributes]
6563- [nogo]
Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ Core Go rules
1313.. _config_setting : https://docs.bazel.build/versions/master/be/general.html#config_setting
1414.. _data dependencies : https://bazel.build/concepts/dependencies#data-dependencies
1515.. _goarch : modes.rst#goarch
16- .. _gofips140 : modes.rst#gofips140
1716.. _goos : modes.rst#goos
1817.. _mode attributes : modes.rst#mode-attributes
1918.. _nogo : nogo.rst#nogo
Original file line number Diff line number Diff line change @@ -69,13 +69,6 @@ or using `Bazel configuration transitions`_.
6969| ``CGO_ENABLED=0 ``). Packages that contain cgo code may still be built, but |
7070| the cgo code will be filtered out, and the ``cgo `` build tag will be false. |
7171+------------------------+---------------------+-------------------------------+
72- | :param: `gofips140 ` | :type: `string ` | :value: `"off" ` |
73- +------------------------+---------------------+-------------------------------+
74- | Controls the ``GOFIPS140 `` environment variable used by Go 1.24+ to select |
75- | the version of the Go Cryptographic Module. Can be set to ``"off" `` |
76- | (default), ``"latest" ``, or a specific version like ``"v1.0.0" ``. |
77- | See the `Go 1.24 FIPS 140-3 documentation `_ for more details. |
78- +------------------------+---------------------+-------------------------------+
7972| :param: `debug ` | :type: `bool ` | :value: `false ` |
8073+------------------------+---------------------+-------------------------------+
8174| Includes debugging information in compiled packages (using the ``-N `` and |
Original file line number Diff line number Diff line change @@ -24,7 +24,10 @@ filegroup(
2424filegroup(
2525 name = "srcs",
2626 srcs = glob(
27- ["src/**/*"],
27+ [
28+ "lib/fips140/**",
29+ "src/**/*",
30+ ],
2831 exclude = [
2932 "src/**/*_test.go",
3033 "src/**/testdata/**",
Original file line number Diff line number Diff line change @@ -167,6 +167,7 @@ def emit_link(
167167 builder_args .add ("-o" , executable )
168168 builder_args .add ("-main" , archive .data .file )
169169 builder_args .add ("-p" , archive .data .importmap )
170+ builder_args .add ("-work" , "-v" )
170171 tool_args .add_all (gc_linkopts )
171172 tool_args .add_all (go .toolchain .flags .link )
172173
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ def _should_use_sdk_stdlib(go):
5959 not go .mode .race and # TODO(jayconrod): use precompiled race
6060 not go .mode .msan and
6161 not go .mode .pure and
62+ go .mode .gofips140 == "off" and
6263 not go .mode .gc_goopts and
6364 go .mode .linkmode == LINKMODE_NORMAL )
6465
@@ -93,6 +94,9 @@ def _build_stdlib_list_json(go):
9394def _build_env (go ):
9495 env = go .env
9596
97+ if go .mode .gofips140 != "off" :
98+ env .update ({"GOFIPS140" : go .mode .gofips140 })
99+
96100 if go .mode .pure :
97101 env .update ({"CGO_ENABLED" : "0" })
98102 return env
Original file line number Diff line number Diff line change @@ -564,6 +564,9 @@ def go_context(
564564 if mode .arm :
565565 env ["GOARM" ] = mode .arm
566566
567+ if mode .gofips140 != "off" :
568+ env ["GOFIPS140" ] = mode .gofips140
569+
567570 if cgo_context_info :
568571 env .update (cgo_context_info .env )
569572 cc_toolchain_files = cgo_context_info .cc_toolchain_files
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ GoSDK = provider(
3535 fields = {
3636 "goos" : "The host OS the SDK was built for." ,
3737 "goarch" : "The host architecture the SDK was built for." ,
38+ "gofips140" : "The value of GOFIPS140 to build with" ,
3839 "experiments" : "Comma-separated Go experiments to enable via GOEXPERIMENT." ,
3940 "root_file" : "A file in the SDK root directory" ,
4041 "libs" : ("Depset of pre-compiled .a files for the standard library " +
Original file line number Diff line number Diff line change @@ -367,13 +367,6 @@ def _go_binary_kwargs(go_cc_aspects = []):
367367 [pure].
368368 """ ,
369369 ),
370- "gofips140" : attr .string (
371- default = "off" ,
372- doc = """Controls the GOFIPS140 environment variable. May be any string value.
373- Common values include `"off"` (default), `"latest"`, and specific versions like `"v1.0.0"`.
374- See [mode attributes], specifically [gofips140].
375- """ ,
376- ),
377370 "static" : attr .string (
378371 default = "auto" ,
379372 doc = """Controls whether a binary is statically linked. May be one of `on`,
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ def _go_sdk_impl(ctx):
3535 GoSDK (
3636 goos = ctx .attr .goos ,
3737 goarch = ctx .attr .goarch ,
38+ gofips140 = ctx .attr .gofips140 ,
3839 experiments = "," .join (ctx .attr .experiments ),
3940 root_file = ctx .file .root_file ,
4041 package_list = package_list ,
@@ -58,6 +59,13 @@ go_sdk = rule(
5859 mandatory = True ,
5960 doc = "The host architecture the SDK was built for" ,
6061 ),
62+ "gofips140" : attr .string (
63+ default = "off" ,
64+ doc = """Controls the GOFIPS140 environment variable. May be any string value.
65+ Common values include `"off"` (default), `"latest"`, and specific versions like `"v1.0.0"`.
66+ See [mode attributes], specifically [gofips140].
67+ """ ,
68+ ),
6169 "experiments" : attr .string_list (
6270 mandatory = False ,
6371 doc = "Go experiments to enable via GOEXPERIMENT" ,
You can’t perform that action at this time.
0 commit comments