Skip to content

Commit

Permalink
Align to the purego build tag, removing noasm build tag
Browse files Browse the repository at this point in the history
The `purego` build tag has been proposed[1] as the de-facto tag for
pure Go builds. This is a superset of the `noasm` tag currently used.

This patch aligns the code base to toggle to pure Go implementation
when `purego` is defined.

Verified that all assembly is excluded by doing:

    find . -name '*.s' -exec sed -i -e '$athis-is-not-valid-assembly 12345' {} \;
    go test --tags purego ./...

[1]: golang/go#23172
  • Loading branch information
mattyclarkson authored and armfazh committed Apr 8, 2024
1 parent a4b7601 commit 2c600ff
Show file tree
Hide file tree
Showing 51 changed files with 85 additions and 77 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ GOARCH ?=
BUILD_ARCH = $(shell $(GO) env GOARCH)

ifeq ($(NOASM),1)
OPTS+=--tags noasm
OPTS+=--tags purego
endif

ifeq ($(V),1)
Expand Down
4 changes: 2 additions & 2 deletions dh/csidh/fp511_amd64.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build amd64 && !noasm
// +build amd64,!noasm
//go:build amd64 && !purego
// +build amd64,!purego

package csidh

Expand Down
3 changes: 2 additions & 1 deletion dh/csidh/fp511_amd64.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// +build amd64
//go:build amd64 && !purego
// +build amd64,!purego

#include "textflag.h"

Expand Down
2 changes: 1 addition & 1 deletion dh/sidh/internal/p434/arith_amd64.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,!noasm
// +build amd64,!purego

#include "textflag.h"

Expand Down
4 changes: 2 additions & 2 deletions dh/sidh/internal/p434/arith_amd64_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dh/sidh/internal/p434/arith_decl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dh/sidh/internal/p434/arith_generic.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dh/sidh/internal/p503/arith_amd64.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,!noasm
// +build amd64,!purego

#include "textflag.h"

Expand Down
4 changes: 2 additions & 2 deletions dh/sidh/internal/p503/arith_amd64_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dh/sidh/internal/p503/arith_arm64.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build arm64,!noasm
// +build arm64,!purego

#include "textflag.h"

Expand Down
4 changes: 2 additions & 2 deletions dh/sidh/internal/p503/arith_decl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dh/sidh/internal/p503/arith_generic.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dh/sidh/internal/p751/arith_amd64.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,!noasm
// +build amd64,!purego

#include "textflag.h"

Expand Down
4 changes: 2 additions & 2 deletions dh/sidh/internal/p751/arith_amd64_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dh/sidh/internal/p751/arith_arm64.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build arm64,!noasm
// +build arm64,!purego

#include "textflag.h"

Expand Down
4 changes: 2 additions & 2 deletions dh/sidh/internal/p751/arith_decl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dh/sidh/internal/p751/arith_generic.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dh/sidh/internal/templates/arith_decl.gotemp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Code generated by go generate; DO NOT EDIT.
// This file was generated by robots.

//go:build {{if .OPT_ARM}}({{end}}amd64 && !noasm{{if .OPT_ARM}}) || (arm64 && !noasm){{end}}
// +build amd64,!noasm{{if .OPT_ARM}} arm64,!noasm{{end}}
//go:build {{if .OPT_ARM}}({{end}}amd64 && !purego{{if .OPT_ARM}}) || (arm64 && !purego){{end}}
// +build amd64,!purego{{if .OPT_ARM}} arm64,!purego{{end}}

package {{.PACKAGE}}

Expand Down
4 changes: 2 additions & 2 deletions dh/sidh/internal/templates/arith_generic.gotemp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Code generated by go generate; DO NOT EDIT.
// This file was generated by robots.

//go:build {{if .OPT_ARM}}noasm || (!amd64 && !arm64){{else}}noasm || !amd64{{end}}
// +build {{if .OPT_ARM}}noasm !amd64,!arm64{{else}}noasm !amd64{{end}}
//go:build {{if .OPT_ARM}}purego || (!amd64 && !arm64){{else}}purego || !amd64{{end}}
// +build {{if .OPT_ARM}}purego !amd64,!arm64{{else}}purego !amd64{{end}}

package {{.PACKAGE}}

Expand Down
3 changes: 2 additions & 1 deletion dh/x25519/curve_amd64.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// +build amd64
//go:build amd64 && !purego
// +build amd64,!purego

#include "textflag.h"

Expand Down
3 changes: 2 additions & 1 deletion dh/x448/curve_amd64.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// +build amd64
//go:build amd64 && !purego
// +build amd64,!purego

#include "textflag.h"

Expand Down
4 changes: 2 additions & 2 deletions ecc/p384/arith.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build (!noasm && arm64) || (!noasm && amd64)
// +build !noasm,arm64 !noasm,amd64
//go:build (!purego && arm64) || (!purego && amd64)
// +build !purego,arm64 !purego,amd64

package p384

Expand Down
4 changes: 2 additions & 2 deletions ecc/p384/arith_amd64.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build amd64 && !noasm
// +build amd64,!noasm
//go:build amd64 && !purego
// +build amd64,!purego

package p384

Expand Down
2 changes: 1 addition & 1 deletion ecc/p384/arith_amd64.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,!noasm
// +build amd64,!purego

#include "textflag.h"

Expand Down
2 changes: 1 addition & 1 deletion ecc/p384/arith_arm64.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build arm64,!noasm
// +build arm64,!purego

#include "textflag.h"

Expand Down
4 changes: 2 additions & 2 deletions ecc/p384/arith_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build (!noasm && arm64) || (!noasm && amd64)
// +build !noasm,arm64 !noasm,amd64
//go:build (!purego && arm64) || (!purego && amd64)
// +build !purego,arm64 !purego,amd64

package p384

Expand Down
4 changes: 2 additions & 2 deletions ecc/p384/opt_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build (!noasm && arm64) || (!noasm && amd64)
// +build !noasm,arm64 !noasm,amd64
//go:build (!purego && arm64) || (!purego && amd64)
// +build !purego,arm64 !purego,amd64

package p384

Expand Down
4 changes: 2 additions & 2 deletions ecc/p384/p384_generic.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build noasm || (!amd64 && !arm64)
// +build noasm !amd64,!arm64
//go:build purego || (!amd64 && !arm64)
// +build purego !amd64,!arm64

package p384

Expand Down
4 changes: 2 additions & 2 deletions ecc/p384/p384opt.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build (!noasm && arm64) || (!noasm && amd64)
// +build !noasm,arm64 !noasm,amd64
//go:build (!purego && arm64) || (!purego && amd64)
// +build !purego,arm64 !purego,amd64

package p384

Expand Down
4 changes: 2 additions & 2 deletions ecc/p384/point.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build (!noasm && arm64) || (!noasm && amd64)
// +build !noasm,arm64 !noasm,amd64
//go:build (!purego && arm64) || (!purego && amd64)
// +build !purego,arm64 !purego,amd64

package p384

Expand Down
4 changes: 2 additions & 2 deletions ecc/p384/point_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build (!noasm && arm64) || (!noasm && amd64)
// +build !noasm,arm64 !noasm,amd64
//go:build (!purego && arm64) || (!purego && amd64)
// +build !purego,arm64 !purego,amd64

package p384

Expand Down
4 changes: 2 additions & 2 deletions ecc/p384/tableBase.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build (!noasm && arm64) || (!noasm && amd64)
// +build !noasm,arm64 !noasm,amd64
//go:build (!purego && arm64) || (!purego && amd64)
// +build !purego,arm64 !purego,amd64

package p384

Expand Down
3 changes: 2 additions & 1 deletion math/fp25519/fp_amd64.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// +build amd64
//go:build amd64 && !purego
// +build amd64,!purego

#include "textflag.h"
#include "fp_amd64.h"
Expand Down
3 changes: 2 additions & 1 deletion math/fp448/fp_amd64.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// +build amd64
//go:build amd64 && !purego
// +build amd64,!purego

#include "textflag.h"
#include "fp_amd64.h"
Expand Down
4 changes: 2 additions & 2 deletions pke/kyber/internal/common/amd64.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build amd64
// +build amd64
//go:build amd64 && !purego
// +build amd64,!purego

package common

Expand Down
2 changes: 1 addition & 1 deletion pke/kyber/internal/common/amd64.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Code generated by command: go run src.go -out ../amd64.s -stubs ../stubs_amd64.go -pkg common. DO NOT EDIT.

//go:build amd64
//go:build amd64 && !purego

#include "textflag.h"

Expand Down
2 changes: 1 addition & 1 deletion pke/kyber/internal/common/asm/src.go
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ func normalizeAVX2() {
}

func main() {
ConstraintExpr("amd64")
ConstraintExpr("amd64,!purego")

addAVX2()
subAVX2()
Expand Down
4 changes: 2 additions & 2 deletions pke/kyber/internal/common/generic.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build !amd64
// +build !amd64
//go:build !amd64 || purego
// +build !amd64 purego

package common

Expand Down
2 changes: 1 addition & 1 deletion pke/kyber/internal/common/stubs_amd64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions sign/dilithium/internal/common/amd64.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build amd64
// +build amd64
//go:build amd64 && !purego
// +build amd64,!purego

package common

Expand Down
2 changes: 1 addition & 1 deletion sign/dilithium/internal/common/amd64.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Code generated by command: go run src.go -out ../amd64.s -stubs ../stubs_amd64.go -pkg common. DO NOT EDIT.

//go:build amd64
//go:build amd64 && !purego

#include "textflag.h"

Expand Down
2 changes: 1 addition & 1 deletion sign/dilithium/internal/common/asm/src.go
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ func mulBy2toDAVX2() {
}

func main() {
ConstraintExpr("amd64")
ConstraintExpr("amd64,!purego")

nttAVX2()
invNttAVX2()
Expand Down
4 changes: 2 additions & 2 deletions sign/dilithium/internal/common/generic.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build !amd64
// +build !amd64
//go:build !amd64 || purego
// +build !amd64 purego

package common

Expand Down
2 changes: 1 addition & 1 deletion sign/dilithium/internal/common/stubs_amd64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions simd/keccakf1600/f1600x2_arm64.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build arm64 && go1.16
// +build arm64,go1.16
//go:build arm64 && go1.16 && !purego
// +build arm64,go1.16,!purego

package keccakf1600

Expand Down
2 changes: 1 addition & 1 deletion simd/keccakf1600/f1600x2_arm64.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build arm64,go1.16
// +build arm64,go1.16,!purego

// Taken from https://github.com/bwesterb/armed-keccak

Expand Down
3 changes: 3 additions & 0 deletions simd/keccakf1600/f1600x4_amd64.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build amd64 && !purego
// +build amd64,!purego

package keccakf1600

import "github.com/cloudflare/circl/internal/sha3"
Expand Down
2 changes: 1 addition & 1 deletion simd/keccakf1600/f1600x4_amd64.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Code generated by command: go run src.go -out ../../f1600x4_amd64.s -stubs ../../f1600x4stubs_amd64.go -pkg keccakf1600. DO NOT EDIT.

//go:build amd64
//go:build amd64 && !purego

#include "textflag.h"

Expand Down
Loading

0 comments on commit 2c600ff

Please sign in to comment.