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

Changed objects files extension to "obj" on windows #38876

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ impl OutputType {
OutputType::Bitcode => "bc",
OutputType::Assembly => "s",
OutputType::LlvmAssembly => "ll",
OutputType::Object if cfg!(target_os = "windows") => "obj",
OutputType::Object => "o",
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this not trigger a dead code warning for one of the two arms depending on target_os?

Copy link
Member

Choose a reason for hiding this comment

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

This doesn't feel right, I'd expect to use the target OS not the host one (of the rustc in use).
That is, this won't use .obj for cross-compilation and that seems wrong to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rkruppe I made a simple program that checks that. It didn't trigger a dead code warning.
@eddyb I agree. I'll see how it can be done.

Copy link
Contributor Author

@liranringel liranringel Jan 6, 2017

Choose a reason for hiding this comment

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

I'd liked to pass Session and use the sess.target.target.options.target_family, but Session is not Sync, and It cannot be sent in run_work_multithreaded.
I wonder how should I pass that information (because it will has to be sent to many functions, so I want it to be part of something like WorkItem or CodegenContext).

Copy link
Member

Choose a reason for hiding this comment

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

You may be able to clone TargetOptions (or whatever the type is called)? That or pre-compute the file names. cc @rust-lang/compiler

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eddyb Oh, it could be part of TargetOptions. Is there a reason that Object is part of OutputType, and TargetOptions (which has exe_suffix, staticlib_suffix...) does not simply have obj_suffix?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think so? Those suffixes seem like the natural place for this though.

OutputType::Metadata => "rmeta",
OutputType::DepInfo => "d",
Expand Down
8 changes: 6 additions & 2 deletions src/librustc_trans/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ pub fn link_binary(sess: &Session,
remove(sess, &obj);
}
}
remove(sess, &outputs.with_extension("metadata.o"));
remove(sess, &outputs.with_extension(&get_metadata_extension()));
}

out_filenames
Expand Down Expand Up @@ -824,7 +824,7 @@ fn link_args(cmd: &mut Linker,
// object file, so we link that in here.
if crate_type == config::CrateTypeDylib ||
crate_type == config::CrateTypeProcMacro {
cmd.add_object(&outputs.with_extension("metadata.o"));
cmd.add_object(&outputs.with_extension(&get_metadata_extension()));
}

// Try to strip as much out of the generated object by removing unused
Expand Down Expand Up @@ -1245,3 +1245,7 @@ fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool {
None => true,
}
}

fn get_metadata_extension() -> String {
"metadata.".to_string() + OutputType::Object.extension()
}