Merge pull request #1599 from kxxt/feat/riscv64
feat(target): add support for riscv64gc-unknown-linux-gnu
This commit is contained in:
commit
ab83d88c57
9 changed files with 93 additions and 6 deletions
53
.github/workflows/linux-riscv64.yaml
vendored
Normal file
53
.github/workflows/linux-riscv64.yaml
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
name: Linux-riscv64
|
||||
|
||||
env:
|
||||
DEBUG: 'napi:*'
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: stable - riscv64-unknown-linux-gnu - node@18
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
cache: 'yarn'
|
||||
|
||||
- name: Install
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
toolchain: stable
|
||||
targets: riscv64gc-unknown-linux-gnu
|
||||
|
||||
- name: Cache cargo
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
key: stable-linux-riscv64-gnu-node@18-cargo-cache
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y gcc-riscv64-linux-gnu
|
||||
yarn config set --json supportedArchitectures.cpu '["current", "riscv64"]'
|
||||
yarn config set supportedArchitectures.libc "glibc"
|
||||
yarn install --immutable --mode=skip-build
|
||||
|
||||
- name: Cross build native tests
|
||||
run: yarn build:test -- --target riscv64gc-unknown-linux-gnu
|
|
@ -94,6 +94,14 @@ jobs:
|
|||
- host: windows-latest
|
||||
target: 'aarch64-pc-windows-msvc'
|
||||
build: yarn build --platform --target aarch64-pc-windows-msvc
|
||||
- host: ubuntu-latest
|
||||
target: 'riscv64gc-unknown-linux-gnu'
|
||||
setup: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install gcc-riscv64-linux-gnu -y
|
||||
build: |
|
||||
yarn build --platform --target riscv64gc-unknown-linux-gnu
|
||||
riscv64-linux-gnu-strip *.node
|
||||
|
||||
name: stable - \${{ matrix.settings.target }} - node@18
|
||||
runs-on: \${{ matrix.settings.host }}
|
||||
|
|
|
@ -85,6 +85,11 @@ function loadNapiModule(binaryName: string, packageName: string) {
|
|||
case 'arm':
|
||||
candidates.push('linux-arm-gnueabihf')
|
||||
break
|
||||
// type Architecture doesn't contain riscv64 yet
|
||||
// @ts-expect-error
|
||||
case 'riscv64':
|
||||
candidates.push('linux-riscv64-gnu')
|
||||
break
|
||||
}
|
||||
break
|
||||
}
|
||||
|
|
|
@ -107,4 +107,11 @@ Generated by [AVA](https://avajs.dev).
|
|||
platformArchABI: 'darwin-universal',
|
||||
triple: 'universal-apple-darwin',
|
||||
},
|
||||
{
|
||||
abi: 'gnu',
|
||||
arch: 'riscv64',
|
||||
platform: 'linux',
|
||||
platformArchABI: 'linux-riscv64-gnu',
|
||||
triple: 'riscv64gc-unknown-linux-gnu',
|
||||
},
|
||||
]
|
||||
|
|
Binary file not shown.
|
@ -99,4 +99,13 @@ export const CIConfig: Partial<
|
|||
],
|
||||
test: false,
|
||||
},
|
||||
'riscv64gc-unknown-linux-gnu': {
|
||||
host: 'ubuntu-latest',
|
||||
build_setup: [
|
||||
'sudo apt-get update',
|
||||
'sudo apt-get install g++-riscv64-linux-gnu gcc-riscv64-linux-gnu -y',
|
||||
],
|
||||
// No official nodejs docker image for riscv64
|
||||
test: false,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ export const AVAILABLE_TARGETS = [
|
|||
'armv7-unknown-linux-gnueabihf',
|
||||
'armv7-linux-androideabi',
|
||||
'universal-apple-darwin',
|
||||
'riscv64gc-unknown-linux-gnu',
|
||||
] as const
|
||||
|
||||
export type TargetTriple = (typeof AVAILABLE_TARGETS)[number]
|
||||
|
@ -27,6 +28,7 @@ export const DEFAULT_TARGETS = [
|
|||
|
||||
export const TARGET_LINKER: Record<string, string> = {
|
||||
'aarch64-unknown-linux-musl': 'aarch64-linux-musl-gcc',
|
||||
'riscv64gc-unknown-linux-gnu': 'riscv64-linux-gnu-gcc',
|
||||
}
|
||||
|
||||
// https://nodejs.org/api/process.html#process_process_arch
|
||||
|
@ -38,6 +40,7 @@ type NodeJSArch =
|
|||
| 'mipsel'
|
||||
| 'ppc'
|
||||
| 'ppc64'
|
||||
| 'riscv64'
|
||||
| 's390'
|
||||
| 's390x'
|
||||
| 'x32'
|
||||
|
@ -49,6 +52,7 @@ const CpuToNodeArch: Record<string, NodeJSArch> = {
|
|||
aarch64: 'arm64',
|
||||
i686: 'ia32',
|
||||
armv7: 'arm',
|
||||
riscv64gc: 'riscv64',
|
||||
}
|
||||
|
||||
export const NodeArchToCpu: Record<string, string> = {
|
||||
|
@ -56,6 +60,7 @@ export const NodeArchToCpu: Record<string, string> = {
|
|||
arm64: 'aarch64',
|
||||
ia32: 'i686',
|
||||
arm: 'armv7',
|
||||
riscv64: 'riscv64gc',
|
||||
}
|
||||
|
||||
const SysToNodePlatform: Record<string, NodeJS.Platform> = {
|
||||
|
|
|
@ -319,12 +319,12 @@ module.exports.platformArchTriples = {
|
|||
"abi": "gnu"
|
||||
}
|
||||
],
|
||||
"riscv64gc": [
|
||||
"riscv64": [
|
||||
{
|
||||
"triple": "riscv64gc-unknown-linux-gnu",
|
||||
"platformArchABI": "linux-riscv64gc-gnu",
|
||||
"platformArchABI": "linux-riscv64-gnu",
|
||||
"platform": "linux",
|
||||
"arch": "riscv64gc",
|
||||
"arch": "riscv64",
|
||||
"abi": "gnu"
|
||||
}
|
||||
],
|
||||
|
|
|
@ -319,12 +319,12 @@ export const platformArchTriples = {
|
|||
"abi": "gnu"
|
||||
}
|
||||
],
|
||||
"riscv64gc": [
|
||||
"riscv64": [
|
||||
{
|
||||
"triple": "riscv64gc-unknown-linux-gnu",
|
||||
"platformArchABI": "linux-riscv64gc-gnu",
|
||||
"platformArchABI": "linux-riscv64-gnu",
|
||||
"platform": "linux",
|
||||
"arch": "riscv64gc",
|
||||
"arch": "riscv64",
|
||||
"abi": "gnu"
|
||||
}
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue