]>
git.proxmox.com Git - rustc.git/blob - vendor/cc/tests/test.rs
1 use crate::support
::Test
;
7 let test
= Test
::gnu();
8 test
.gcc().file("foo.c").compile("foo");
15 .must_have("-ffunction-sections")
16 .must_have("-fdata-sections");
17 test
.cmd(1).must_have(test
.td
.path().join("foo.o"));
21 fn gnu_opt_level_1() {
22 let test
= Test
::gnu();
23 test
.gcc().opt_level(1).file("foo.c").compile("foo");
25 test
.cmd(0).must_have("-O1").must_not_have("-O2");
29 fn gnu_opt_level_s() {
30 let test
= Test
::gnu();
31 test
.gcc().opt_level_str("s").file("foo.c").compile("foo");
38 .must_not_have("-Oz");
42 fn gnu_debug_fp_auto() {
43 let test
= Test
::gnu();
44 test
.gcc().debug(true).file("foo.c").compile("foo");
45 test
.cmd(0).must_have("-g");
46 test
.cmd(0).must_have("-fno-omit-frame-pointer");
51 let test
= Test
::gnu();
52 test
.gcc().debug(true).file("foo.c").compile("foo");
53 test
.cmd(0).must_have("-g");
54 test
.cmd(0).must_have("-fno-omit-frame-pointer");
59 let test
= Test
::gnu();
62 .force_frame_pointer(false)
65 test
.cmd(0).must_have("-g");
66 test
.cmd(0).must_not_have("-fno-omit-frame-pointer");
68 let test
= Test
::gnu();
70 .force_frame_pointer(false)
74 test
.cmd(0).must_have("-g");
75 test
.cmd(0).must_not_have("-fno-omit-frame-pointer");
79 fn gnu_warnings_into_errors() {
80 let test
= Test
::gnu();
82 .warnings_into_errors(true)
86 test
.cmd(0).must_have("-Werror");
91 let test
= Test
::gnu();
94 .flag("-Wno-missing-field-initializers")
98 test
.cmd(0).must_have("-Wall").must_have("-Wextra");
102 fn gnu_extra_warnings0() {
103 let test
= Test
::gnu();
106 .extra_warnings(false)
107 .flag("-Wno-missing-field-initializers")
111 test
.cmd(0).must_have("-Wall").must_not_have("-Wextra");
115 fn gnu_extra_warnings1() {
116 let test
= Test
::gnu();
119 .extra_warnings(true)
120 .flag("-Wno-missing-field-initializers")
124 test
.cmd(0).must_not_have("-Wall").must_have("-Wextra");
128 fn gnu_warnings_overridable() {
129 let test
= Test
::gnu();
132 .flag("-Wno-missing-field-initializers")
137 .must_have_in_order("-Wall", "-Wno-missing-field-initializers");
142 for vendor
in &["unknown-linux-gnu", "apple-darwin"] {
143 let target
= format
!("x86_64-{}", vendor
);
144 let test
= Test
::gnu();
151 test
.cmd(0).must_have("-fPIC").must_have("-m64");
156 fn gnu_x86_64_no_pic() {
157 for vendor
in &["unknown-linux-gnu", "apple-darwin"] {
158 let target
= format
!("x86_64-{}", vendor
);
159 let test
= Test
::gnu();
167 test
.cmd(0).must_not_have("-fPIC");
173 for vendor
in &["unknown-linux-gnu", "apple-darwin"] {
174 let target
= format
!("i686-{}", vendor
);
175 let test
= Test
::gnu();
182 test
.cmd(0).must_have("-m32");
188 for vendor
in &["unknown-linux-gnu", "apple-darwin"] {
189 let target
= format
!("i686-{}", vendor
);
190 let test
= Test
::gnu();
198 test
.cmd(0).must_have("-fPIC");
203 fn gnu_x86_64_no_plt() {
204 let target
= "x86_64-unknown-linux-gnu";
205 let test
= Test
::gnu();
213 test
.cmd(0).must_have("-fno-plt");
217 fn gnu_set_stdlib() {
218 let test
= Test
::gnu();
220 .cpp_set_stdlib(Some("foo"))
224 test
.cmd(0).must_not_have("-stdlib=foo");
229 let test
= Test
::gnu();
230 test
.gcc().include("foo/bar").file("foo.c").compile("foo");
232 test
.cmd(0).must_have("-I").must_have("foo/bar");
237 let test
= Test
::gnu();
239 .define("FOO", "bar")
244 test
.cmd(0).must_have("-DFOO=bar").must_have("-DBAR");
248 fn gnu_compile_assembly() {
249 let test
= Test
::gnu();
250 test
.gcc().file("foo.S").compile("foo");
251 test
.cmd(0).must_have("foo.S");
256 let test
= Test
::gnu();
263 test
.cmd(0).must_have("-shared").must_not_have("-static");
267 fn gnu_flag_if_supported() {
271 let test
= Test
::gnu();
275 .flag_if_supported("-Wall")
276 .flag_if_supported("-Wflag-does-not-exist")
277 .flag_if_supported("-std=c++11")
283 .must_not_have("-Wflag-does-not-exist")
284 .must_not_have("-std=c++11");
288 fn gnu_flag_if_supported_cpp() {
292 let test
= Test
::gnu();
296 .flag_if_supported("-std=c++11")
299 test
.cmd(0).must_have("-std=c++11");
304 let test
= Test
::gnu();
311 test
.cmd(0).must_have("-static").must_not_have("-shared");
316 let test
= Test
::msvc();
317 test
.gcc().file("foo.c").compile("foo");
322 .must_not_have("-Z7")
325 test
.cmd(1).must_have(test
.td
.path().join("foo.o"));
329 fn msvc_opt_level_0() {
330 let test
= Test
::msvc();
331 test
.gcc().opt_level(0).file("foo.c").compile("foo");
333 test
.cmd(0).must_not_have("-O2");
338 let test
= Test
::msvc();
339 test
.gcc().debug(true).file("foo.c").compile("foo");
340 test
.cmd(0).must_have("-Z7");
345 let test
= Test
::msvc();
346 test
.gcc().include("foo/bar").file("foo.c").compile("foo");
348 test
.cmd(0).must_have("-I").must_have("foo/bar");
353 let test
= Test
::msvc();
355 .define("FOO", "bar")
360 test
.cmd(0).must_have("-DFOO=bar").must_have("-DBAR");
364 fn msvc_static_crt() {
365 let test
= Test
::msvc();
366 test
.gcc().static_crt(true).file("foo.c").compile("foo");
368 test
.cmd(0).must_have("-MT");
372 fn msvc_no_static_crt() {
373 let test
= Test
::msvc();
374 test
.gcc().static_crt(false).file("foo.c").compile("foo");
376 test
.cmd(0).must_have("-MD");