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

Can't build sysroot #525

Open
hhamud opened this issue May 26, 2024 · 17 comments
Open

Can't build sysroot #525

hhamud opened this issue May 26, 2024 · 17 comments

Comments

@hhamud
Copy link

hhamud commented May 26, 2024

Can't build sysroot with mac m1.

I've already tried to run clean all and then prepare again but it failed.

https://pastebin.com/EVp68ZxA

@antoyo
Copy link
Contributor

antoyo commented May 26, 2024

What is your linker? Is it clang?

@hhamud
Copy link
Author

hhamud commented May 26, 2024

What is your linker? Is it clang?

yeah

user@192 rustc_codegen_gcc % clang --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: arm64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

@antoyo
Copy link
Contributor

antoyo commented May 27, 2024

From what I can see in your logs, it seems there was a _ (underscore) prepended to the function names like _gcc_jit_type_dyncast_vector.
I'm not familiar with macOS: do you know if this is something that happens on this OS?

@hhamud
Copy link
Author

hhamud commented May 27, 2024

From what I can see in your logs, it seems there was a _ (underscore) prepended to the function names like _gcc_jit_type_dyncast_vector. I'm not familiar with macOS: do you know if this is something that happens on this OS?

it looks like it does.

How do I run the gcc backend with this flag? -fno-leading-underscore

@antoyo
Copy link
Contributor

antoyo commented May 27, 2024

Set this environment variable before building the sysroot CG_RUSTFLAGS=-Cllvm-args=-fno-leading-underscore.

@hhamud
Copy link
Author

hhamud commented May 28, 2024

Set this environment variable before building the sysroot CG_RUSTFLAGS=-Cllvm-args=-fno-leading-underscore.

I still get the same problem when running these commands to try again

CG_RUSTFLAGS=-Cllvm-args=-fno-leading-underscore ./y.sh clean all
CG_RUSTFLAGS=-Cllvm-args=-fno-leading-underscore ./y.sh prepare
CG_RUSTFLAGS=-Cllvm-args=-fno-leading-underscore ./y.sh build sysroot --release

I think it might just be a compatibility issue with the arm architecture.

@antoyo
Copy link
Contributor

antoyo commented May 29, 2024

I just looked back at your logs and it's actually not the sysroot that you cannot build, it's rustc_codegen_gcc itself.
How did you build libgccjit?

Since I was able to build the sysroot on a Mac M1 with Asahi Linux, I believe this is related to macOS and not the hardware.

I believe this is more related to macOS ABI, so perhaps you built libgccjit with the wrong ABI?

@hhamud
Copy link
Author

hhamud commented May 29, 2024

I just looked back at your logs and it's actually not the sysroot that you cannot build, it's rustc_codegen_gcc itself. How did you build libgccjit?

Since I was able to build the sysroot on a Mac M1 with Asahi Linux, I believe this is related to macOS and not the hardware.

I believe this is more related to macOS ABI, so perhaps you built libgccjit with the wrong ABI?

I just copied the config.toml file as shown in the example and it downloaded that when I ran the commands.

@GuillaumeGomez
Copy link
Member

I think it's why it doesn't work: it's compiled for linux. You need to build gcc yourself to be able to use it.

@hhamud
Copy link
Author

hhamud commented May 29, 2024

I think it's why it doesn't work: it's compiled for linux. You need to build gcc yourself to be able to use it.

ok I will try out cloning gcc and follow the instructions to compile it myself.

@hhamud
Copy link
Author

hhamud commented May 29, 2024

I got an error when following the gcc instructions to compile my own libgccjit.

after following these steps but converting them into macos supported packages and instructions.

$ git clone https://github.com/antoyo/gcc

$ cd gcc

$ brew install flex mpfr gmp libmpc

$ mkdir gcc-build gcc-install

$ cd gcc-build

$ ../gcc/configure \
    --enable-host-shared \
    --enable-languages=jit \
    --enable-checking=release \
    --disable-bootstrap \
    --disable-multilib \
    --prefix=$(pwd)/../gcc-install \

I got this error

*** Configuration aarch64-apple-darwin22.6.0 not supported

Update:

I have found a mac os compatible gcc repo, I just need to apply antoyo's patch to this and I will be all set. The diff is too large and I don't know enough on how gcc works to apply it appropriately.

@antoyo can you make a note in the docs that macos is incompatible for the time being.

@antoyo
Copy link
Contributor

antoyo commented Jun 7, 2024

Yes, I will add the note that macOS is currently incompatible.

Do you know how much the repo you found diverges from upstream?
If there are not many changes, perhaps I could include the changes in my GCC fork.

@hhamud
Copy link
Author

hhamud commented Jun 7, 2024

Yes, I will add the note that macOS is currently incompatible.

Do you know how much the repo you found diverges from upstream? If there are not many changes, perhaps I could include the changes in my GCC fork.

I have the git diff between the two repos and its pretty chunky.

its uploaded here

https://file.io/K4Cwyuna6Oth

@antoyo
Copy link
Contributor

antoyo commented Jun 7, 2024

Just to make sure, did you do the diff betwee these 2 repos:

?

@hhamud
Copy link
Author

hhamud commented Jun 7, 2024

Just to make sure, did you do the diff betwee these 2 repos:

* https://github.com/gcc-mirror/gcc

* https://github.com/iains/gcc-darwin-arm64

?

no specifically your patched version.

@antoyo
Copy link
Contributor

antoyo commented Jun 7, 2024

Ok, my fork is 2379 commits behind compared to upstream, so that might be why there are so many changes.

I was asking if you compared with https://github.com/gcc-mirror/gcc to know if it would be easy to add the changes required for macOS if I rebase my fork.

@hhamud
Copy link
Author

hhamud commented Jun 7, 2024

Ok, my fork is 2379 commits behind compared to upstream, so that might be why there are so many changes.

I was asking if you compared with https://github.com/gcc-mirror/gcc to know if it would be easy to add the changes required for macOS if I rebase my fork.

ok here's the diff between master gcc and gcc-darwin-arm64 master-wip-apple-si

diff.patch

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

No branches or pull requests

3 participants