@@ -645,9 +645,16 @@ pub fn build_session_options(binary: @~str,
645
645
Some(s) => s
646
646
};
647
647
648
- let addl_lib_search_paths =
649
- getopts::opt_strs(matches, ~" L ")
650
- .map(|s| Path(*s));
648
+ let addl_lib_search_paths = getopts::opt_strs(matches, ~" L ").map(|s| Path(*s));
649
+
650
+ let linker_args = getopts::opt_strs(matches, ~" linker").flat_map( |a| {
651
+ let mut args = ~[];
652
+ for str::each_split_char(*a, ',') |arg| {
653
+ args.push(str::from_slice(arg));
654
+ }
655
+ args
656
+ });
657
+
651
658
let cfg = parse_cfgspecs(getopts::opt_strs(matches, ~" cfg"), demitter);
652
659
let test = opt_present(matches, ~" test");
653
660
let android_cross_path = getopts::opt_maybe_str(
@@ -664,6 +671,7 @@ pub fn build_session_options(binary: @~str,
664
671
jit: jit,
665
672
output_type: output_type,
666
673
addl_lib_search_paths: addl_lib_search_paths,
674
+ linker_args: linker_args,
667
675
maybe_sysroot: sysroot_opt,
668
676
target_triple: target,
669
677
target_feature: target_feature,
@@ -737,62 +745,66 @@ pub fn parse_pretty(sess: Session, name: &str) -> pp_mode {
737
745
// rustc command line options
738
746
pub fn optgroups ( ) -> ~[ getopts:: groups:: OptGroup ] {
739
747
~[
740
- optflag ( ~"", ~"bin", ~"Compile an executable crate ( default) ") ,
741
- optflag ( ~"c", ~" ", ~"Compile and assemble, but do not link") ,
742
- optmulti ( ~"", ~"cfg", ~"Configure the compilation
743
- environment", ~"SPEC ") ,
744
- optflag ( ~"", ~"emit-llvm",
745
- ~"Produce an LLVM bitcode file") ,
746
- optflag ( ~"h", ~"help", ~"Display this message") ,
747
- optmulti ( ~"L ", ~"", ~"Add a directory to the library search path",
748
- ~"PATH ") ,
749
- optflag ( ~"", ~"lib", ~"Compile a library crate") ,
750
- optflag ( ~"", ~"ls", ~"List the symbols defined by a library crate") ,
751
- optflag ( ~"", ~"no-trans",
752
- ~"Run all passes except translation; no output") ,
753
- optflag ( ~"O ", ~"", ~"Equivalent to --opt-level=2 ") ,
754
- optopt ( ~"o", ~"", ~"Write output to <filename>", ~" FILENAME ") ,
755
- optopt ( ~"", ~"opt-level",
756
- ~"Optimize with possible levels 0 -3 ", ~"LEVEL ") ,
757
- optopt ( ~"", ~"out-dir",
758
- ~"Write output to compiler-chosen filename
759
- in <dir>", ~" DIR ") ,
760
- optflag ( ~"", ~"parse-only",
761
- ~"Parse only; do not compile, assemble, or link") ,
762
- optflagopt ( ~"", ~"pretty",
763
- ~"Pretty -print the input instead of compiling;
748
+ optflag ( "" , "bin" , "Compile an executable crate (default)" ) ,
749
+ optflag ( "c" , "" , "Compile and assemble, but do not link" ) ,
750
+ optmulti ( "" , "cfg" , "Configure the compilation
751
+ environment" , "SPEC" ) ,
752
+ optflag ( "" , "emit-llvm" ,
753
+ "Produce an LLVM bitcode file" ) ,
754
+ optflag ( "h" , "help" , "Display this message" ) ,
755
+ optmulti ( "L" , "" , "Add a directory to the library search path" ,
756
+ "PATH" ) ,
757
+ optflag ( "" , "lib" , "Compile a library crate" ) ,
758
+ optmulti ( "" , "linker" , "FLAGS is a comma-separated list of flags
759
+ passed to the linker" , "FLAGS" ) ,
760
+ optflag ( "" , "ls" , "List the symbols defined by a library crate" ) ,
761
+ optflag ( "" , "no-trans" ,
762
+ "Run all passes except translation; no output" ) ,
763
+ optflag ( "O" , "" , "Equivalent to --opt-level=2" ) ,
764
+ optopt ( "o" , "" , "Write output to <filename>" , "FILENAME" ) ,
765
+ optopt ( "" , "opt-level" ,
766
+ "Optimize with possible levels 0-3" , "LEVEL" ) ,
767
+ optopt ( "" , "out-dir" ,
768
+ "Write output to compiler-chosen filename
769
+ in <dir>" , "DIR" ) ,
770
+ optflag ( "" , "parse-only" ,
771
+ "Parse only; do not compile, assemble, or link" ) ,
772
+ optflagopt ( "" , "pretty" ,
773
+ "Pretty-print the input instead of compiling;
764
774
valid types are: normal (un-annotated source),
765
775
expanded (crates expanded),
766
776
typed (crates expanded, with type annotations),
767
777
or identified (fully parenthesized,
768
- AST nodes and blocks with IDs ) ", ~"TYPE ") ,
769
- optflag ( ~"S ", ~"", ~"Compile only; do not assemble or link") ,
770
- optflag ( ~"", ~"save-temps",
771
- ~"Write intermediate files ( . bc , . opt . bc , . o )
778
+ AST nodes and blocks with IDs)" , "TYPE" ) ,
779
+ optflag ( "" , "print-link-args" , "Prints all the arguments that would be
780
+ passed to the linker." ) ,
781
+ optflag ( "S" , "" , "Compile only; do not assemble or link" ) ,
782
+ optflag ( "" , "save-temps" ,
783
+ "Write intermediate files (.bc, .opt.bc, .o)
772
784
in addition to normal output" ) ,
773
- optopt ( ~ "", ~ "sysroot",
774
- ~ "Override the system root", ~ "PATH ") ,
775
- optflag ( ~ "", ~ "test", ~ "Build a test harness") ,
776
- optopt( ~ "", ~ "target",
777
- ~ "Target triple cpu-manufacturer-kernel[ -os]
785
+ optopt ( "" , "sysroot" ,
786
+ "Override the system root" , "PATH" ) ,
787
+ optflag ( "" , "test" , "Build a test harness" ) ,
788
+ optopt ( "" , "target" ,
789
+ "Target triple cpu-manufacturer-kernel[-os]
778
790
to compile for (see chapter 3.4 of http://www.sourceware.org/autobook/
779
- for detail) ", ~ "TRIPLE ") ,
780
- optopt( ~ "", ~ "target-feature",
781
- ~ "Target specific attributes ( llc -mattr=help
782
- for detail) ", ~ "FEATURE ") ,
783
- optopt( ~ "", ~ "android-cross-path",
784
- ~ "The path to the Android NDK ", "PATH" ) ,
785
- optmulti( ~ "W ", ~ "warn",
786
- ~ "Set lint warnings", ~ "OPT ") ,
787
- optmulti( ~ "A ", ~ "allow",
788
- ~ "Set lint allowed", ~ "OPT ") ,
789
- optmulti( ~ "D ", ~ "deny",
790
- ~ "Set lint denied", ~ "OPT ") ,
791
- optmulti( ~ "F ", ~ "forbid",
792
- ~ "Set lint forbidden", ~ "OPT ") ,
793
- optmulti( ~ "Z ", ~ "", ~ "Set internal debugging options", "FLAG" ) ,
794
- optflag( ~ "v", ~ "version",
795
- ~ "Print version info and exit") ,
791
+ for detail)" , "TRIPLE" ) ,
792
+ optopt ( "" , "target-feature" ,
793
+ "Target specific attributes (llc -mattr=help
794
+ for detail)" , "FEATURE" ) ,
795
+ optopt ( "" , "android-cross-path" ,
796
+ "The path to the Android NDK" , "PATH" ) ,
797
+ optmulti ( "W" , "warn" ,
798
+ "Set lint warnings" , "OPT" ) ,
799
+ optmulti ( "A" , "allow" ,
800
+ "Set lint allowed" , "OPT" ) ,
801
+ optmulti ( "D" , "deny" ,
802
+ "Set lint denied" , "OPT" ) ,
803
+ optmulti ( "F" , "forbid" ,
804
+ "Set lint forbidden" , "OPT" ) ,
805
+ optmulti ( "Z" , "" , "Set internal debugging options" , "FLAG" ) ,
806
+ optflag ( "v" , "version" ,
807
+ "Print version info and exit" ) ,
796
808
]
797
809
}
798
810
0 commit comments