Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: add dynamic linker option for riscv64 #1159

Closed
wants to merge 1 commit into from

Conversation

Avimitin
Copy link
Contributor

@Avimitin Avimitin commented Nov 16, 2022

This commit add dynamic linker for riscv 64 architecture. Tested in Arch Linux rv64gc qemu user image.

Addtional notes:

The old go module golang.org/x/sys doesn't contains implementation for RISC-V. We need to replace the module with v0.2.0.

cd src
go mod edit -replace golang.org/x/sys=golang.org/x/[email protected]
go mod download golang.org/x/sys

I don't know if this upgrade will affect the program, so changes are not included in this PR.

@softwarefactory-project-zuul
Copy link

Build succeeded.

✔️ unit-test SUCCESS in 7m 31s
✔️ unit-test-migration-path-for-coreos-toolbox SUCCESS in 7m 31s
✔️ system-test-fedora-rawhide SUCCESS in 26m 57s
✔️ system-test-fedora-36 SUCCESS in 9m 56s
✔️ system-test-fedora-35 SUCCESS in 11m 03s

Copy link
Member

@debarshiray debarshiray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this, @Avimitin ! The patch looks mostly good.

Could you please prefix your commit message with a build: tag and put a link at the bottom to this pull request, like we do in the other commits?

Out of curiosity, are you using Toolbx on riscv64 or generally interested in the architecture in some way?

@debarshiray
Copy link
Member

The old go module golang.org/x/sys doesn't contains
implementation for RISC-V. We need to replace the module
with v0.2.0.

Are you sure about this one? Currently, our go.mod has:

golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e

That's this commit. Support for linux/riscv64 was added in this commit, which looks older. Or am I missing something?

@Avimitin
Copy link
Contributor Author

Avimitin commented Nov 18, 2022

Oh I have to force push to reword commit, sry

This commit add dynamic linker for riscv 64 architecture.
Tested in Arch Linux rv64gc qemu user image.

Signed-off-by: Avimitin <[email protected]>
@Avimitin
Copy link
Contributor Author

Avimitin commented Nov 18, 2022

Out of curiosity, are you using Toolbx on riscv64 or generally interested in the architecture in some way?

I am now working for an unofficial project that porting the Arch Linux packages to RISC-V. And this package failed to build so I tried to fix it.

@Avimitin
Copy link
Contributor Author

Avimitin commented Nov 18, 2022

Are you sure about this one? Currently, our go.mod has:

golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e

That's this commit. Support for linux/riscv64 was added in this commit, which looks older. Or am I missing something?

My description is not accurate enough. The current sys package did has rv64 implementation but is not complete. So the Go compiler complaining missing function body during compilation process. I don't know which function is missing and I will try to figure it out.

@Avimitin Avimitin changed the title Add dynamic linker option for riscv64 build add dynamic linker option for riscv64 Nov 18, 2022
@Avimitin Avimitin changed the title build add dynamic linker option for riscv64 build: add dynamic linker option for riscv64 Nov 18, 2022
@softwarefactory-project-zuul
Copy link

Build succeeded.

✔️ unit-test SUCCESS in 8m 23s
✔️ unit-test-migration-path-for-coreos-toolbox SUCCESS in 8m 24s
✔️ system-test-fedora-rawhide SUCCESS in 35m 33s
✔️ system-test-fedora-36 SUCCESS in 11m 02s
✔️ system-test-fedora-35 SUCCESS in 12m 05s

@debarshiray
Copy link
Member

Out of curiosity, are you using Toolbx on riscv64 or generally interested
in the architecture in some way?

I am now working for an unofficial project that porting the Arch Linux
packages to RISC-V. And this package failed to build so I tried to fix it.

That sounds like an interesting project. :)

@debarshiray
Copy link
Member

Are you sure about this one? Currently, our go.mod has:

golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e

That's this commit. Support for linux/riscv64 was added in this commit, which looks older. Or am I missing something?

My description is not accurate enough. The current sys package did has rv64 implementation but is not complete. So the Go compiler complaining missing function body during compilation process. I don't know which function is missing and I will try to figure it out.

I see. Could it be because of this commit. Maybe we should try updating the dependency to this commit?

I think we also need to bump our required Go version to 1.14 in src/go.mod from the current 1.13.

@Avimitin
Copy link
Contributor Author

I see. Could it be because of this commit. Maybe we should try updating the dependency to this commit?

Probably not this one, I am still try digging. Here is the full compile error output:

# golang.org/x/sys/unix
/build/go/pkg/mod/golang.org/x/[email protected]/unix/syscall_linux_gc.go:10:6: missing function body
/build/go/pkg/mod/golang.org/x/[email protected]/unix/syscall_linux_gc.go:14:6: missing function body
/build/go/pkg/mod/golang.org/x/[email protected]/unix/syscall_unix_gc.go:12:6: missing function body
/build/go/pkg/mod/golang.org/x/[email protected]/unix/syscall_unix_gc.go:13:6: missing function body
/build/go/pkg/mod/golang.org/x/[email protected]/unix/syscall_unix_gc.go:14:6: missing function body
/build/go/pkg/mod/golang.org/x/[email protected]/unix/syscall_unix_gc.go:15:6: missing function body

@Avimitin
Copy link
Contributor Author

Avimitin commented Nov 18, 2022

Oh my fault, I don't explain the whole build environment. The current version of the toolbox package in Arch Linux is 0.0.99.33. I will try if the v0.0.0-20211216021012-1d35b9e2eb4e version of the sys package specified in master branch works.

@Avimitin
Copy link
Contributor Author

I've verified the v0.0.0-20211216021012-1d35b9e2eb4e version of the sys package can be compiled on RISC-V platform. So no need to upgrade the go.mod file. We will patch the old version ourselves.

And I am still trying to verify the minimal required version.

@debarshiray
Copy link
Member

I've verified the v0.0.0-20211216021012-1d35b9e2eb4e version of the sys package can be compiled on RISC-V platform. So no need to upgrade the go.mod file. We will patch the old version ourselves.

And I am still trying to verify the minimal required version.

Fantastic!

Do you think we also need to bump our required Go version to 1.14 in src/go.mod from the current 1.13?

@Avimitin
Copy link
Contributor Author

Avimitin commented Dec 2, 2022

Do you think we also need to bump our required Go version to 1.14 in src/go.mod from the current 1.13?

Yes, this is required. Should I push the change in this PR?

@debarshiray
Copy link
Member

I've verified the v0.0.0-20211216021012-1d35b9e2eb4e version of the sys package can be compiled on RISC-V platform. So no need to upgrade the go.mod file. We will patch the old version ourselves.

And I am still trying to verify the minimal required version.

Meanwhile, we updated our golang.org/x/sys requirement to 0.1.0.

debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Jun 13, 2023
Go 1.14 added experimental support for 64-bit RISC-V on Linux
(GOOS=linux, GOARCH=riscv64) [1], and the path of the dynamic linker
(ie., PT_INTERP) was taken from the ABI specification [2].

Tested in Arch Linux rv64gc qemu user image.

[1] https://tip.golang.org/doc/go1.14#riscv

[2] https://sourceware.org/glibc/wiki/ABIList

containers#1159

Signed-off-by: Avimitin <[email protected]>
debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Jun 13, 2023
Go 1.14 added experimental support for 64-bit RISC-V on Linux
(GOOS=linux, GOARCH=riscv64) [1], and the path of the dynamic linker
(ie., PT_INTERP) was taken from the ABI specification [2].

Tested in Arch Linux rv64gc qemu user image.

[1] https://tip.golang.org/doc/go1.14#riscv

[2] https://sourceware.org/glibc/wiki/ABIList

containers#1159
containers#1316

Signed-off-by: Avimitin <[email protected]>
debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Jun 13, 2023
Go 1.14 added experimental support for 64-bit RISC-V on Linux
(GOOS=linux, GOARCH=riscv64) [1], and the path of the dynamic linker
(ie., PT_INTERP) was taken from the ABI specification [2].

Tested in Arch Linux rv64gc qemu user image.

[1] https://tip.golang.org/doc/go1.14#riscv

[2] https://sourceware.org/glibc/wiki/ABIList

containers#1159
containers#1316

Signed-off-by: Avimitin Lu <[email protected]>
@debarshiray
Copy link
Member

Do you think we also need to bump our required Go version to 1.14 in src/go.mod from the current 1.13?

Yes, this is required. Should I push the change in this PR?

I took the liberty to update this branch by bumping the required Go version to 1.14 and rebasing against main, but:

[rishi@topinka toolbox]$ git push --force Avimitin Avimitin-dynamic-linker:wip/rishi/Avimitin-dynamic-linker
Enumerating objects: 1341, done.
Counting objects: 100% (1341/1341), done.
Delta compression using up to 16 threads
Compressing objects: 100% (817/817), done.
Writing objects: 100% (1254/1254), 177.90 KiB | 2.40 MiB/s, done.
Total 1254 (delta 863), reused 536 (delta 350), pack-reused 0
remote: Resolving deltas: 100% (863/863), completed with 54 local objects.
To github.com:Avimitin/toolbox-riscv64-linker.git
 ! [remote rejected]           Avimitin-dynamic-linker -> wip/rishi/Avimitin-dynamic-linker (permission denied)
error: failed to push some refs to 'github.com:Avimitin/toolbox-riscv64-linker.git'

So, I pushed it to #1316

@debarshiray
Copy link
Member

Merged through #1316

Closing this one.

@debarshiray
Copy link
Member

Thanks for working on this, @Avimitin !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants