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

Redesign output flags for rustc #12020

Merged
merged 1 commit into from
Feb 6, 2014
Merged

Conversation

alexcrichton
Copy link
Member

This commit removes the -c, --emit-llvm, -s, --rlib, --dylib, --staticlib,
--lib, and --bin flags from rustc, adding the following flags:

  • --emit=[asm,ir,bc,obj,link]
  • --crate-type=[dylib,rlib,staticlib,bin,lib]

The -o option has also been redefined to be used for all flavors of outputs.
This means that we no longer ignore it for libraries. The --out-dir remains the
same as before.

The new logic for files that rustc emits is as follows:

  1. Output types are dictated by the --emit flag. The default value is
    --emit=link, and this option can be passed multiple times and have all options
    stacked on one another.
  2. Crate types are dictated by the --crate-type flag and the #[crate_type]
    attribute. The flags can be passed many times and stack with the crate
    attribute.
  3. If the -o flag is specified, and only one output type is specified, the
    output will be emitted at this location. If more than one output type is
    specified, then the filename of -o is ignored, and all output goes in the
    directory that -o specifies. The -o option always ignores the --out-dir
    option.
  4. If the --out-dir flag is specified, all output goes in this directory.
  5. If -o and --out-dir are both not present, all output goes in the directory of
    the crate file.
  6. When multiple output types are specified, the filestem of all output is the
    same as the name of the CrateId (derived from a crate attribute or from the
    filestem of the crate file).

Closes #7791
Closes #11056
Closes #11667

@huonw
Copy link
Member

huonw commented Feb 4, 2014

Needs a rebase already!

@alexcrichton
Copy link
Member Author

Oops, should be better now!

@brson
Copy link
Contributor

brson commented Feb 4, 2014

When multiple output types are specified is -o an error?

Is the behavior of outputing in the same directory as the source by default consistent with other compilers? Seems like gcc outputs to the current directory. I know this behavior has bugged me before when manually building stuff from the rust tree ('why would i want to output my binary all the way over there?!').

@alexcrichton
Copy link
Member Author

Multiple output types + -o is implemented as a warning.

That's a good point about the current directory, I'll investigate.

@alexcrichton
Copy link
Member Author

Investigation:

  • gcc - output to the current directory
  • clang - output to the current directory
  • go build - output to the current directory
  • dmd - output to the current directory
  • haskell - output next to the source file

From this data, I'd be more inclined to output to the current directory rather than next to the source file.

// have to make up a name
// We want to toss everything after the final '.'
let dirpath = match *odir {
Some(ref d) => (*d).clone(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this taking a ref then dereferencing? (same below)

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, I think this is some old code from perhaps when autoderef wasn't working quite as well. I shall update.

@brson
Copy link
Contributor

brson commented Feb 5, 2014

I'm not sure about 'exe' as an 'emit' type since it implies the output is executable. How about 'link'?

@alexcrichton
Copy link
Member Author

Updated with exe => link

This commit removes the -c, --emit-llvm, -s, --rlib, --dylib, --staticlib,
--lib, and --bin flags from rustc, adding the following flags:

* --emit=[asm,ir,bc,obj,link]
* --crate-type=[dylib,rlib,staticlib,bin,lib]

The -o option has also been redefined to be used for *all* flavors of outputs.
This means that we no longer ignore it for libraries. The --out-dir remains the
same as before.

The new logic for files that rustc emits is as follows:

1. Output types are dictated by the --emit flag. The default value is
   --emit=link, and this option can be passed multiple times and have all
   options stacked on one another.
2. Crate types are dictated by the --crate-type flag and the #[crate_type]
   attribute. The flags can be passed many times and stack with the crate
   attribute.
3. If the -o flag is specified, and only one output type is specified, the
   output will be emitted at this location. If more than one output type is
   specified, then the filename of -o is ignored, and all output goes in the
   directory that -o specifies. The -o option always ignores the --out-dir
   option.
4. If the --out-dir flag is specified, all output goes in this directory.
5. If -o and --out-dir are both not present, all output goes in the current
   directory of the process.
6. When multiple output types are specified, the filestem of all output is the
   same as the name of the CrateId (derived from a crate attribute or from the
   filestem of the crate file).

Closes rust-lang#7791
Closes rust-lang#11056
Closes rust-lang#11667
bors added a commit that referenced this pull request Feb 6, 2014
This commit removes the -c, --emit-llvm, -s, --rlib, --dylib, --staticlib,
--lib, and --bin flags from rustc, adding the following flags:

* --emit=[asm,ir,bc,obj,link]
* --crate-type=[dylib,rlib,staticlib,bin,lib]

The -o option has also been redefined to be used for *all* flavors of outputs.
This means that we no longer ignore it for libraries. The --out-dir remains the
same as before.

The new logic for files that rustc emits is as follows:

1. Output types are dictated by the --emit flag. The default value is
   --emit=link, and this option can be passed multiple times and have all options
   stacked on one another.
2. Crate types are dictated by the --crate-type flag and the #[crate_type]
   attribute. The flags can be passed many times and stack with the crate
   attribute.
3. If the -o flag is specified, and only one output type is specified, the
   output will be emitted at this location. If more than one output type is
   specified, then the filename of -o is ignored, and all output goes in the
   directory that -o specifies. The -o option always ignores the --out-dir
   option.
4. If the --out-dir flag is specified, all output goes in this directory.
5. If -o and --out-dir are both not present, all output goes in the directory of
   the crate file.
6. When multiple output types are specified, the filestem of all output is the
   same as the name of the CrateId (derived from a crate attribute or from the
   filestem of the crate file).

Closes #7791
Closes #11056
Closes #11667
@bors bors closed this Feb 6, 2014
@bors bors merged commit 6e7968b into rust-lang:master Feb 6, 2014
@alexcrichton alexcrichton deleted the output-flags branch February 7, 2014 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants