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

Grep for call my_func in the LTO test #591

Open
antoyo opened this issue Jan 12, 2025 · 8 comments · May be fixed by #600
Open

Grep for call my_func in the LTO test #591

antoyo opened this issue Jan 12, 2025 · 8 comments · May be fixed by #600
Assignees
Labels
good first issue Good for newcomers tests

Comments

@antoyo
Copy link
Contributor

antoyo commented Jan 12, 2025

Here

@antoyo antoyo added good first issue Good for newcomers tests labels Jan 12, 2025
@Anon258
Copy link

Anon258 commented Jan 13, 2025

Hello, I would like to work on this issue

@antoyo
Copy link
Contributor Author

antoyo commented Jan 13, 2025

Nice!
Basically, the test should check that there's no call to my_func in the generated asm, meaning that there was inlining between different crates.
If you have any questions, don't hesitate to ask.

@Anon258
Copy link

Anon258 commented Jan 14, 2025

I am trying to build with LTO using

EMBED_LTO_BITCODE=1 CHANNEL="debug" ./y.sh cargo build --manifest-path tests/hello-world/Cargo.toml

However after building, i checked the binary with objdump -dj .text target/debug/hello_world. I can see the asm for call present

00000000000efab1 <_ZN11hello_world4main17h248b5759c97214e8E>:
   efab1:	55                   	push   %rbp
   efab2:	48 89 e5             	mov    %rsp,%rbp
   efab5:	48 83 ec 60          	sub    $0x60,%rsp
   efab9:	be 0a 00 00 00       	mov    $0xa,%esi
   efabe:	bf 05 00 00 00       	mov    $0x5,%edi
   efac3:	e8 2a ff 02 00       	call   11f9f2 <_ZN5mylib7my_func17hb2cbd8e97cd6f643E>

Am I doing something wrong? LTO is not being setup correctly

@antoyo
Copy link
Contributor Author

antoyo commented Jan 14, 2025

You might be missing the --release flag to you y.sh cargo build command in order to enable the optimizations that would do the inlining.

@Anon258 Anon258 linked a pull request Jan 15, 2025 that will close this issue
@Anon258
Copy link

Anon258 commented Jan 15, 2025

I am trying to understand the code a bit more, what exactly is the difference between gcc-13.deb and libgccjit.so? It seems the release.yml uses gcc-13.deb as gcc-path, but the default build systems installs libgccjit instead.
Because if i run the steps

$ ./y.sh prepare
$ ./y.sh build --sysroot
$ EMBED_LTO_BITCODE=1 CHANNEL="debug" ./y.sh cargo build --release --manifest-path tests/hello-world/Cargo.toml

I get the error,

x86_64-pc-linux-gnu-gcc-15.0.0: fatal error: ‘-fuse-linker-plugin’, but liblto_plugin.so not found

However I can find the lib in /usr/lib/gcc

$ ls -la /usr/lib/gcc/x86_64-linux-gnu/11/liblto_plugin.so 
-rw-r--r-- 1 root root 89120 May 13  2023 /usr/lib/gcc/x86_64-linux-gnu/11/liblto_plugin.so

@antoyo
Copy link
Contributor Author

antoyo commented Jan 15, 2025

Try to comment this line: it might not be necessary anymore as the comment above suggests and will make it easier to use LTO locally (since it won't require having the exact same version of the gcc driver and libgccjit.so, which is usually required for LTO so that they use the same version of the intermediate representation).

@Anon258
Copy link

Anon258 commented Jan 15, 2025

It seems that it is not correctly reading the gcc path I think? Since I again get an error

x86_64-pc-linux-gnu-gcc-15.0.0: fatal error: cannot execute ‘lto1’: posix_spawnp: No such file or directory

However, lto1 is also a file present in /usr/lib/gcc

 ls -la /usr/lib/gcc/x86_64-linux-gnu/11/lto1
-rwxr-xr-x 1 root root 24887296 May 13  2023 /usr/lib/gcc/x86_64-linux-gnu/11/lto1

@antoyo
Copy link
Contributor Author

antoyo commented Jan 15, 2025

GCC needs to use the same version for both lto and libgccjit so /usr/lib/gcc/x86_64-linux-gnu/11/ is not going to work.

How did you build libgccjit?
If you followed the instructions there, it's missing the lto frontend, so you would need to configure with it --enable-languages=jit,lto.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers tests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants