diff --git a/.github/build/friendly-filenames.json b/.github/build/friendly-filenames.json index e6679aedd370..6282fb7e5f3d 100644 --- a/.github/build/friendly-filenames.json +++ b/.github/build/friendly-filenames.json @@ -1,11 +1,10 @@ { "android-arm64": { "friendlyName": "android-arm64-v8a" }, + "android-amd64": { "friendlyName": "android-amd64" }, "darwin-amd64": { "friendlyName": "macos-64" }, "darwin-arm64": { "friendlyName": "macos-arm64-v8a" }, - "freebsd-386": { "friendlyName": "freebsd-32" }, "freebsd-amd64": { "friendlyName": "freebsd-64" }, "freebsd-arm64": { "friendlyName": "freebsd-arm64-v8a" }, - "freebsd-arm7": { "friendlyName": "freebsd-arm32-v7a" }, "linux-386": { "friendlyName": "linux-32" }, "linux-amd64": { "friendlyName": "linux-64" }, "linux-arm5": { "friendlyName": "linux-arm32-v5" }, @@ -14,19 +13,15 @@ "linux-arm7": { "friendlyName": "linux-arm32-v7a" }, "linux-mips64le": { "friendlyName": "linux-mips64le" }, "linux-mips64": { "friendlyName": "linux-mips64" }, - "linux-mipslesoftfloat": { "friendlyName": "linux-mips32le-softfloat" }, "linux-mipsle": { "friendlyName": "linux-mips32le" }, - "linux-mipssoftfloat": { "friendlyName": "linux-mips32-softfloat" }, "linux-mips": { "friendlyName": "linux-mips32" }, "linux-ppc64le": { "friendlyName": "linux-ppc64le" }, "linux-ppc64": { "friendlyName": "linux-ppc64" }, "linux-riscv64": { "friendlyName": "linux-riscv64" }, "linux-loong64": { "friendlyName": "linux-loong64" }, "linux-s390x": { "friendlyName": "linux-s390x" }, - "openbsd-386": { "friendlyName": "openbsd-32" }, "openbsd-amd64": { "friendlyName": "openbsd-64" }, "openbsd-arm64": { "friendlyName": "openbsd-arm64-v8a" }, - "openbsd-arm7": { "friendlyName": "openbsd-arm32-v7a" }, "windows-386": { "friendlyName": "windows-32" }, "windows-amd64": { "friendlyName": "windows-64" }, "windows-arm64": { "friendlyName": "windows-arm64-v8a" } diff --git a/.github/workflows/extended-nightly.yml b/.github/workflows/extended-nightly.yml new file mode 100644 index 000000000000..7505b2eb8dcc --- /dev/null +++ b/.github/workflows/extended-nightly.yml @@ -0,0 +1,76 @@ +name: Extended or Back-seated Nightly Build +# Secondary builds are built here. +# Failing maybe not meaning a blocking. This is a judgement call. + +on: + workflow_dispatch: + push: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + permissions: + contents: write + strategy: + matrix: + include: + - goos: openbsd + goarch: amd64 + assetname: openbsd-64 + - goos: openbsd + goarch: arm64 + assetname: openbsd-arm64-v8a + fail-fast: false + + runs-on: ubuntu-latest + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + CGO_ENABLED: 0 + steps: + - name: Checkout codebase + uses: actions/checkout@v6 + + - name: Show workflow information + run: | + _NAME=${{ matrix.assetname }} + echo "GOOS: $GOOS, GOARCH: $GOARCH, RELEASE_NAME: $_NAME" + echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version-file: go.mod + check-latest: true + + - name: Get project dependencies + run: go mod download + + - name: Build Xray + run: | + if [[ ${GOARCH} == 'arm' ]]; then + GOARM="7" + fi + # Building + mkdir -p build_assets + COMMID=$(git describe --always --dirty) + if [[ ${GOOS} == 'windows' ]]; then + echo 'Building Xray for Windows...' + go build -o build_assets/xray.exe -trimpath -buildvcs=false -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main + else + echo 'Building Xray...' + go build -o build_assets/xray -trimpath -buildvcs=false -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main + fi + + - name: Copy README.md & LICENSE + run: | + cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md + cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE + + - name: Upload files to Artifacts + uses: actions/upload-artifact@v7 + with: + name: Xray-${{ env.ASSET_NAME }} + path: | + ./build_assets/* diff --git a/.github/workflows/release-win7.yml b/.github/workflows/release-win7.yml index 9d777bc05dea..391fe38a518b 100644 --- a/.github/workflows/release-win7.yml +++ b/.github/workflows/release-win7.yml @@ -1,4 +1,7 @@ name: Build and Release for Windows 7 +# The furthest build might happen in August 2028 before a newer monor version of Go 1 releases. +# The furthest build must before Go 2 releases. +# Multiple factors may affect this procedure. on: workflow_dispatch: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 33ab9c43987f..6e56d46779ac 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,86 +78,66 @@ jobs: contents: write strategy: matrix: - # Include amd64 on all platforms. - goos: [windows, freebsd, openbsd, linux, darwin] - goarch: [amd64, 386] + # Include x86-64 and ARM64 on all platforms. + goos: [windows, freebsd, linux, darwin, android] + goarch: [amd64, arm64] patch-assetname: [""] - exclude: - # Exclude i386 on darwin - - goarch: 386 - goos: darwin + # Building for OpenBSD has been suspended unless there are active + # contributors that uses OpenBSD actively. + # PRs for OpenBSD compatibility are welcome. + # Building for BSDs will be add back when there is active maintenance. include: - # BEGIN MacOS ARM64 - - goos: darwin - goarch: arm64 - # END MacOS ARM64 - # BEGIN Linux ARM 5 6 7 + # BEGIN RISCV & LoongArch - goos: linux - goarch: arm - goarm: 7 + goarch: riscv64 - goos: linux - goarch: arm - goarm: 6 + goarch: loong64 + # END RISCV & LoongArch + # BEGIN PPC - goos: linux - goarch: arm - goarm: 5 - # END Linux ARM 5 6 7 - # BEGIN Android ARM 8 - - goos: android - goarch: arm64 - # END Android ARM 8 - # BEGIN Android AMD64 - - goos: android - goarch: amd64 - patch-assetname: android-amd64 - # END Android AMD64 - # Windows ARM - - goos: windows - goarch: arm64 - # BEGIN Other architectures - # BEGIN riscv64 & ARM64 & LOONG64 + goarch: ppc64 - goos: linux - goarch: arm64 + goarch: ppc64le + # END PPC + # BEGIN S390X - goos: linux - goarch: riscv64 + goarch: s390x + # END S390X + # BEGIN x86 + # Removing x86 32-bit on Linux will depending on upstream. - goos: linux - goarch: loong64 - # END riscv64 & ARM64 & LOONG64 + goarch: 386 + # Back-seating x86 32-bit on Windows (not win7) will be in v27. + - goos: windows + goarch: 386 + # END x86 # BEGIN MIPS + # MIPS64 BE/LE will be removed in v27 - goos: linux goarch: mips64 - goos: linux goarch: mips64le + # MIPS32 BE/LE will be back-seated in v27. + # This is a long tail architecture due to router productions. - goos: linux goarch: mipsle - goos: linux goarch: mips # END MIPS - # BEGIN PPC + # BEGIN Linux ARM + # ARMv7 is a long tail - goos: linux - goarch: ppc64 - - goos: linux - goarch: ppc64le - # END PPC - # BEGIN FreeBSD ARM - - goos: freebsd - goarch: arm64 - - goos: freebsd goarch: arm goarm: 7 - # END FreeBSD ARM - # BEGIN S390X + # ARMv6 will be removed in v27 - goos: linux - goarch: s390x - # END S390X - # END Other architectures - # BEGIN OPENBSD ARM - - goos: openbsd - goarch: arm64 - - goos: openbsd goarch: arm - goarm: 7 - # END OPENBSD ARM + goarm: 6 + # ARMv5 will be removed in v27 + - goos: linux + goarch: arm + goarm: 5 + # END Linux ARM fail-fast: false runs-on: ubuntu-latest @@ -186,8 +166,8 @@ jobs: - name: Show workflow information run: | _NAME=${{ matrix.patch-assetname }} - [ -n "$_NAME" ] || _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM$GOMIPS\"].friendlyName" -r < .github/build/friendly-filenames.json) - echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, GOMIPS: $GOMIPS, RELEASE_NAME: $_NAME" + [ -n "$_NAME" ] || _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM\"].friendlyName" -r < .github/build/friendly-filenames.json) + echo "GOOS: $GOOS, GOARCH: $GOARCH, RELEASE_NAME: $_NAME" echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV - name: Set up Go @@ -201,6 +181,29 @@ jobs: - name: Build Xray run: | + # Special processing for ARM64 + if [[ ${GOARCH} == 'arm64' ]]; then + if [[ ${GOOS} == 'darwin' ]]; then + GOARM64="v8.4" + fi + if [[ ${GOOS} == 'windows' ]]; then + GOARM64="v8.2" + fi + fi + # Special processing for x86-64 + if [[ ${GOARCH} == 'amd64' ]]; then + if [[ ${GOOS} == 'darwin' ]]; then + GOAMD64="v3" + fi + if [[ ${GOOS} == 'windows' ]]; then + GOAMD64="v2" + fi + fi + # Special processing for 32-bit ARM + if [[ ${GOARCH} == 'arm' ]] && [[ ${GOOS} != 'linux' ]]; then + GOARM="7" + fi + # Building mkdir -p build_assets COMMID=$(git describe --always --dirty) if [[ ${GOOS} == 'windows' ]]; then diff --git a/README.md b/README.md index f2001426f8ca..d4cb0e38119e 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,30 @@ Make sure that you are using the same Go version, and remember to set the git co CGO_ENABLED=0 go build -o xray -trimpath -buildvcs=false -gcflags="all=-l=4" -ldflags="-X github.com/xtls/xray-core/core.build=REPLACE -s -w -buildid=" -v ./main ``` +If you are compiling a Windows x86-64 target, add this environment variable before compiling: + +``` +GOAMD64=v2 +``` + +If you are compiling a macOS x86-64 target, add this environment variable before compiling: + +``` +GOAMD64=v3 +``` + +If you are compiling a Windows ARM64 target, add this environment variable before compiling: + +``` +GOARM64=v8.2 +``` + +If you are compiling a macOS ARM64 target, add this environment variable before compiling: + +``` +GOARM64=v8.4 +``` + If you are compiling a 32-bit MIPS/MIPSLE target, use this command instead: ```bash diff --git a/common/buf/readv_posix.go b/common/buf/readv_posix.go index e8b3bd7fdb15..5469ad8e4c4d 100644 --- a/common/buf/readv_posix.go +++ b/common/buf/readv_posix.go @@ -1,5 +1,5 @@ -//go:build !windows && !wasm && !illumos && !openbsd -// +build !windows,!wasm,!illumos,!openbsd +//go:build !windows && !openbsd +// +build !windows,!openbsd package buf diff --git a/common/buf/readv_reader.go b/common/buf/readv_reader.go index 7d7b3ead3db6..8b3b8c1617c3 100644 --- a/common/buf/readv_reader.go +++ b/common/buf/readv_reader.go @@ -1,5 +1,5 @@ -//go:build !wasm && !openbsd -// +build !wasm,!openbsd +//go:build !openbsd +// +build !openbsd package buf diff --git a/common/buf/readv_reader_stub.go b/common/buf/readv_reader_stub.go index b2be9825f17e..b86f5dc0cbad 100644 --- a/common/buf/readv_reader_stub.go +++ b/common/buf/readv_reader_stub.go @@ -1,5 +1,5 @@ -//go:build wasm || openbsd -// +build wasm openbsd +//go:build openbsd +// +build openbsd package buf diff --git a/common/buf/readv_test.go b/common/buf/readv_test.go index 6df4c4e8f143..089f0e713921 100644 --- a/common/buf/readv_test.go +++ b/common/buf/readv_test.go @@ -1,5 +1,5 @@ -//go:build !wasm && !openbsd -// +build !wasm,!openbsd +//go:build !openbsd +// +build !openbsd package buf_test diff --git a/common/buf/readv_unix.go b/common/buf/readv_unix.go deleted file mode 100644 index f5ac6ad1e344..000000000000 --- a/common/buf/readv_unix.go +++ /dev/null @@ -1,37 +0,0 @@ -//go:build illumos -// +build illumos - -package buf - -import "golang.org/x/sys/unix" - -type unixReader struct { - iovs [][]byte -} - -func (r *unixReader) Init(bs []*Buffer) { - iovs := r.iovs - if iovs == nil { - iovs = make([][]byte, 0, len(bs)) - } - for _, b := range bs { - iovs = append(iovs, b.v) - } - r.iovs = iovs -} - -func (r *unixReader) Read(fd uintptr) int32 { - n, e := unix.Readv(int(fd), r.iovs) - if e != nil { - return -1 - } - return int32(n) -} - -func (r *unixReader) Clear() { - r.iovs = r.iovs[:0] -} - -func newMultiReader() multiReader { - return &unixReader{} -} diff --git a/transport/internet/sockopt_other.go b/transport/internet/sockopt_other.go index 7e91110e4cc1..86ed1ee21ab1 100644 --- a/transport/internet/sockopt_other.go +++ b/transport/internet/sockopt_other.go @@ -1,5 +1,5 @@ -//go:build js || netbsd || openbsd || solaris -// +build js netbsd openbsd solaris +//go:build !windows && !darwin && !linux && !android && !freebsd +// +build !windows,!darwin,!linux,!android,!freebsd package internet