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

Fix build system #9

Closed
wants to merge 23 commits into from
Closed

Conversation

mubarak23
Copy link

No description provided.

@@ -29,6 +29,16 @@ impl BuildArg {
);
}
}
"--sysroot" => {
if let Some(arg) = args.next() {
build_arg.flags.push("--sysroot".to_string());
Copy link
Owner

Choose a reason for hiding this comment

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

This is not what should be done.

Instead, this new --sysroot flag that you added should be used to determine if we should build the sysroot or not. This happens here.

Copy link
Author

Choose a reason for hiding this comment

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

instead we should call build_sysroot(&env, &args.config_info)?; on the if check

Copy link
Owner

Choose a reason for hiding this comment

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

In this function, set a new field that you can add on this struct to true and in the link from my comment above, wrap the call to build_sysroot in an if that will check if this new field is set to true.

Copy link
Author

Choose a reason for hiding this comment

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

adding a boolean flag on this BuildArg, then set it to TRUE on --sysroot passed

@@ -138,6 +138,16 @@ impl TestArg {
return Err("Expected an argument after `--features`, found nothing".into())
}
},
"--sysroot" => match args.next() {
Copy link
Owner

Choose a reason for hiding this comment

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

This file already contain an option to build the sysroot here, so it should not be needed.

Copy link
Author

Choose a reason for hiding this comment

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

i will remove this

Copy link
Owner

@antoyo antoyo left a comment

Choose a reason for hiding this comment

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

The CI failed, so the code needs a fix, but looks good otherwise.

@@ -9,6 +9,7 @@ use std::path::Path;
struct BuildArg {
flags: Vec<String>,
config_info: ConfigInfo,
sys_root: bool,
Copy link
Owner

Choose a reason for hiding this comment

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

I would prefer this spelling:

Suggested change
sys_root: bool,
sysroot: bool,

@mubarak23
Copy link
Author

what could make the CI failed

@antoyo
Copy link
Owner

antoyo commented Mar 24, 2024

You can see the results of the CI at the bottom of this page. If you click on this one, for example, it shows you the build errors.

@antoyo
Copy link
Owner

antoyo commented Mar 24, 2024

There's still one error (and a warning) to fix in the CI. Keep up the good work.

Btw, do you get notified for the CI failures?

@mubarak23
Copy link
Author

Yes I get notifications for CI failure ,
I will look into it and push a fix

@mubarak23
Copy link
Author

the error is from arg.sysroot = true; on looking at the code again, i am suppose to use build_arg.sysroot= true

@antoyo
Copy link
Owner

antoyo commented Mar 24, 2024

The new error in the CI is because you now need to use this new --sysroot flag in the CI jobs that are in this directory.

@mubarak23
Copy link
Author

you mean something like this cargo clippy --all-targets --sysroot master -- -D warnings in ci.yml file

@antoyo
Copy link
Owner

antoyo commented Mar 24, 2024

No, the argument you added is for the build command from the build system, so whenever you see ./y.sh build, please add --sysroot after.

@mubarak23
Copy link
Author

Alright

Copy link
Owner

@antoyo antoyo left a comment

Choose a reason for hiding this comment

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

It seems the sysroot is still not built in the CI.

Does this work locally on your side?

@@ -220,8 +225,11 @@ fn build_codegen(args: &mut BuildArg) -> Result<(), String> {
})?;

println!("[BUILD] sysroot");
Copy link
Owner

Choose a reason for hiding this comment

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

Please move this line inside the if.

Copy link
Author

Choose a reason for hiding this comment

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

Alright, could be the reason why the CI is failing

@mubarak23
Copy link
Author

It seems the sysroot is still not built in the CI.

Does this work locally on your side?

am getting the following on local macbookpro@MacBooks-MBP-2 rustc_codegen_gcc % ./y.sh build --sysroot

[BUILD] build system
    Finished `release` profile [optimized] target(s) in 0.02s

@@ -224,7 +224,6 @@ fn build_codegen(args: &mut BuildArg) -> Result<(), String> {
)
})?;

println!("[BUILD] sysroot");
if args.sysroot {
Copy link
Owner

Choose a reason for hiding this comment

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

I mean to actually move it like this:

     println!("[BUILD] sysroot");		
     if args.sysroot {

Copy link
Author

Choose a reason for hiding this comment

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

i see

@antoyo
Copy link
Owner

antoyo commented Mar 24, 2024

It seems the sysroot is still not built in the CI.
Does this work locally on your side?

am getting the following on local macbookpro@MacBooks-MBP-2 rustc_codegen_gcc % ./y.sh build --sysroot

[BUILD] build system
    Finished `release` profile [optimized] target(s) in 0.02s

You're missing the actual build of the sysroot.
If you run ./y.sh build on the master branch, you get this which is the expected result:

[BUILD] build system
   Compiling y v0.1.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_system)
    Finished `release` profile [optimized] target(s) in 1.35s
    Finished `dev` profile [optimized + debuginfo] target(s) in 0.05s
[BUILD] sysroot
    Updating crates.io index
   Compiling core v0.0.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/core)
   Compiling compiler_builtins v0.1.108
   Compiling libc v0.2.153
   Compiling std v0.0.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/std)
   Compiling rustc-std-workspace-core v1.99.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/rustc-std-workspace-core)
   Compiling alloc v0.0.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/alloc)
   Compiling cfg-if v1.0.0
   Compiling adler v1.0.2
   Compiling memchr v2.7.1
   Compiling rustc-demangle v0.1.23
   Compiling unwind v0.0.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/unwind)
   Compiling rustc-std-workspace-alloc v1.99.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/rustc-std-workspace-alloc)
   Compiling panic_unwind v0.0.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/panic_unwind)
   Compiling panic_abort v0.0.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/panic_abort)
   Compiling gimli v0.28.1
   Compiling miniz_oxide v0.7.2
   Compiling std_detect v0.1.5 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/stdarch/crates/std_detect)
   Compiling object v0.32.2
   Compiling hashbrown v0.14.3
   Compiling addr2line v0.21.0
   Compiling rustc-std-workspace-std v1.99.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/rustc-std-workspace-std)
   Compiling proc_macro v0.0.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/proc_macro)
   Compiling unicode-width v0.1.11
   Compiling getopts v0.2.21
   Compiling test v0.0.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/test)
   Compiling sysroot v0.0.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 48.27s

Do you know why it doesn't work with the code from this PR?

@mubarak23
Copy link
Author

It seems the sysroot is still not built in the CI.
Does this work locally on your side?

am getting the following on local macbookpro@MacBooks-MBP-2 rustc_codegen_gcc % ./y.sh build --sysroot

[BUILD] build system
    Finished `release` profile [optimized] target(s) in 0.02s

You're missing the actual build of the sysroot. If you run ./y.sh build on the master branch, you get this which is the expected result:

[BUILD] build system
   Compiling y v0.1.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_system)
    Finished `release` profile [optimized] target(s) in 1.35s
    Finished `dev` profile [optimized + debuginfo] target(s) in 0.05s
[BUILD] sysroot
    Updating crates.io index
   Compiling core v0.0.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/core)
   Compiling compiler_builtins v0.1.108
   Compiling libc v0.2.153
   Compiling std v0.0.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/std)
   Compiling rustc-std-workspace-core v1.99.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/rustc-std-workspace-core)
   Compiling alloc v0.0.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/alloc)
   Compiling cfg-if v1.0.0
   Compiling adler v1.0.2
   Compiling memchr v2.7.1
   Compiling rustc-demangle v0.1.23
   Compiling unwind v0.0.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/unwind)
   Compiling rustc-std-workspace-alloc v1.99.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/rustc-std-workspace-alloc)
   Compiling panic_unwind v0.0.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/panic_unwind)
   Compiling panic_abort v0.0.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/panic_abort)
   Compiling gimli v0.28.1
   Compiling miniz_oxide v0.7.2
   Compiling std_detect v0.1.5 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/stdarch/crates/std_detect)
   Compiling object v0.32.2
   Compiling hashbrown v0.14.3
   Compiling addr2line v0.21.0
   Compiling rustc-std-workspace-std v1.99.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/rustc-std-workspace-std)
   Compiling proc_macro v0.0.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/proc_macro)
   Compiling unicode-width v0.1.11
   Compiling getopts v0.2.21
   Compiling test v0.0.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot/sysroot_src/library/test)
   Compiling sysroot v0.0.0 (/home/bouanto/Ordinateur/Programmation/Rust/Projets/rustc_codegen_gcc/build_sysroot)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 48.27s

Do you know why it doesn't work with the code from this PR?

i have no idea, i will switch to the master and run the build

@mubarak23
Copy link
Author

Looking at logs again, i keep seeing error below, as found here

 ---- lang_tests::gep.rs stderr ----

error[E0463]: can't find crate for `std` 
error: could not compile `rustc_codegen_gcc` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: linking with `cc` failed: exit status: 1
``` [found here](https://github.com/antoyo/rustc_codegen_gcc/actions/runs/8412062922/job/23032446290?pr=9)

@antoyo
Copy link
Owner

antoyo commented Mar 25, 2024

Yes, this is because the sysroot is not actually built.
Somehow, your PR changed the build system in a way that prevent the sysroot to be built (even with the --sysroot flag).
You need to figure out why this is happening.
As mentioned before, you should see [BUILD] sysroot in the logs.

@mubarak23
Copy link
Author

I will look at the places where I made the changes on my branch and compare it the place on the master branch

@mubarak23
Copy link
Author

after looking at where i made change on my PR Branch and the master branch, this is piece of code that i addedcreate_dir(gccjit_target)?;

gccjit_target, error
)
})?;

Copy link
Owner

Choose a reason for hiding this comment

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

Perhas you could try print the field to see if we actually reach this line before the if:

println!("Build sysroot: {}", args.sysroot);

Choose a reason for hiding this comment

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

Yaah, i will try this

Copy link
Owner

Choose a reason for hiding this comment

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

It is not even printed, so we don't even reach this code.
Do you have any idea what in this PR could have the effect of skipping this code?

Copy link
Author

Choose a reason for hiding this comment

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

I suspect the build command

Copy link
Owner

Choose a reason for hiding this comment

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

You can try adding println! calls in a few places (especially where you changed the code) to see where it stops happening.

Copy link
Author

@mubarak23 mubarak23 Mar 27, 2024

Choose a reason for hiding this comment

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

so far, this is the only place, we added the sysroot flag

- name: Build
      run: |
        ./y.sh prepare --only-libcore
        ./y.sh build --sysroot
        cargo test

in the ci.yml file
i remove it from all other places i added it

@mubarak23
Copy link
Author

i will add args.sysroot = false; in run() function

@mubarak23
Copy link
Author

where could this error come from error[E0463]: can't find crate for std``

@antoyo
Copy link
Owner

antoyo commented Mar 27, 2024

This is because the sysroot is not built. Building the sysroot means building std among other things.

@mubarak23
Copy link
Author

should i pull out a new branch from master and push my work on it, i feel like the current branch on this PR is currupt

@antoyo
Copy link
Owner

antoyo commented Mar 27, 2024

Yes, you can do that.

@antoyo
Copy link
Owner

antoyo commented Apr 7, 2024

Was superceeded by #13.

@antoyo antoyo closed this Apr 7, 2024
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