Skip to content

support target arm #482

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

Merged
merged 2 commits into from
Dec 28, 2017
Merged

support target arm #482

merged 2 commits into from
Dec 28, 2017

Conversation

rainboh
Copy link

@rainboh rainboh commented Dec 27, 2017

changed types to be compatibe with target "arm-unknown-linux-musleabihf"

@tailhook
Copy link
Owner

Well, I think we can use lchown from libc? I think the reason we have an extern declaration` is that function was absent in some old version of libc.

@rainboh
Copy link
Author

rainboh commented Dec 28, 2017

Good suggestion. Changed it to use llibc::lchown

@rainboh
Copy link
Author

rainboh commented Dec 28, 2017

Btw. As mentioned in #481 (comment) this is the only change needed in vagga repo so far (), to get debug build with "target=arm-unknown-linux-musleabihf" working on pi2

@tailhook tailhook merged commit dc837fe into tailhook:master Dec 28, 2017
@tailhook
Copy link
Owner

Merged. Thanks!

Btw. As mentioned in #481 (comment) this is the only change needed in vagga repo so far ()

You mean that it works if compiling on PI itself. All other problems mentioned there is because of cross-compiling, right?

@rainboh
Copy link
Author

rainboh commented Dec 28, 2017

You mean that it works if compiling on Pi itself.

No. On Pi itself all dependent crates get compiled but when cargo comes to 'vagga' the system gets overloaded. I tried but then I reseted the Pi after some hours because I was to lazy to wait. Guess linking all crates is too much for Pi.

All other problems mentioned there is because of cross-compiling, right?

Correct. But so far I can only workaround the qsort_r issue by patching the libgit2 code.

Only working setup at moment is:

  • patch libgit 2
  • x-compile for "target=armv7-unknown-linux-musleabihf" (no release build)

But the created vagga executable works fine. No strange issues detected so far when playing around.

Of course 'container building' speed on Pi is slow. Don't know if it is as to be expected, or if it can be tuned somehow.

@tailhook
Copy link
Owner

Aha, okay, I don't think there are many people who build on Pi, so I don't think it matters.

Can you make a pull request to libgit2? We can feature-gate libgit2 if needed but probably PR is the best.

@rainboh
Copy link
Author

rainboh commented Dec 29, 2017

Can you make a pull request to libgit2?

No. I commented a check which is no proper solution. If I make a PR I don't expect it will get merged.

If I compile vagga with

cargo build --target=arm-unknown-linux-musleabihf

crate libz-sys (needed by libgit2) fails.

If I compile vagga with

CC=arm-linux-gnueabihf-gcc cargo build --target=arm-unknown-linux-musleabihf

linking fails because 'qsort_r' is missing (which seems to be expected for musl libgit2/libgit2#3438 (comment))

First I need to figure out if I do the wright thing, means 'Is it correct if I set CC for cargo build ?'

I opened issue rust-lang/libz-sys#35
Let's hope that I asked the right questions.

@tailhook
Copy link
Owner

First I need to figure out if I do the wright thing, means 'Is it correct if I set CC for cargo build ?'

I guess yes. While libz-sys cargo could detect it, linker will fail in the same way when libz will successfully compile.

linking fails because 'qsort_r' is missing (which seems to be expected for musl libgit2/libgit2#3438 (comment))

Looks like it's because you use gnu headers instead of musl ones by default. Here is how I can compile it: #483 (nowhere to test though)

@rainboh
Copy link
Author

rainboh commented Dec 30, 2017

Looks like it's because you use gnu headers instead of musl ones by default.

You are right. Source code is ready for 'arm'. Looks like issue is setting up correct header/lib path for compile/linking.

Meanwhile I freed up some space on SD and mem on my Pi and retried to build on Pi itself where I expect correct settings for headers and libs. I tried :

1. cargo build --target=arm-unknown-linux-musleabihf
2. CC=musl-gcc cargo build --target=arm-unknown-linux-musleabihf
3. CC=musl-gcc cargo build --target=arm-unknown-linux-musleabihf --release
  1. fails with same 'qsort_r' linking error
  2. success
  3. fails because linker run out of mem. I will later spend some swap space and retry.

I expected 1. to be successfull too because on my x86_64 it's sufficient to

cargo build --target=x86_64-unknown-linux-musl

while on Pi I need to add 'CC=musl-gcc'.

Here is how I can compile it: #483 (nowhere to test though)

Fails for me. I left comment on other thread

@tailhook
Copy link
Owner

fails with same 'qsort_r' linking error

Different headers. You can also use CFLAGS=-I/usr/include/arm-linux-musleabihf but CC is also okay probably

fails because linker run out of mem. I will later spend some swap space and retry.

You can also try disable LTO, make less number of threads, and opt-level = "s" instead of default 3. Or maybe just lower it.

Do you think providing a package for arm is useful?

@rainboh
Copy link
Author

rainboh commented Dec 31, 2017

You can also use CFLAGS=-I/usr/include/arm-linux-musleabihf but CC is also okay probably

Correct. Setting include path instead of CC is also building properly on Pi

CFLAGS=-I/usr/include/arm-linux-musleabihf cargo build --target=arm-unknown-linux-musleabihf

Do you think providing a package for arm is useful?

Of course a package would make life easier.
Sorry, I have no knowledge about package building and can't support here.

No idea how many people have a use case for vagga on their Pi (or other arm devices). On the other side if people know it's possible they will start to think about and usage will increase.

As it is a matter of priority and time I would say arm package can wait (unless it's almost no effort for you to implement needed build steps). CI is more important. And maybe some hints 'howto use vagga on arm'.

@rainboh rainboh deleted the support-target-arm branch January 1, 2018 18:30
@Kochise
Copy link

Kochise commented Mar 3, 2022

Fyi, qsort_r has been added to Alpine on 2021/09/22 (musl-1.2.2-r7) :

https://gitlab.alpinelinux.org/alpine/aports/-/commit/bf5bbfdbf780092f387b7abe401fbfceda90c84d

Profit.

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.

3 participants