From f6aedfaeebbf465717ba519978c78ab0016030b3 Mon Sep 17 00:00:00 2001 From: Vadzim Dambrouski Date: Mon, 17 Jul 2017 00:38:23 +0300 Subject: [PATCH 1/2] Fix duplicated exception handlers. --- src/generate.rs | 57 +++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/src/generate.rs b/src/generate.rs index 23c85142..c52e33f9 100644 --- a/src/generate.rs +++ b/src/generate.rs @@ -35,11 +35,9 @@ pub fn device( if *target != Target::None { items.push(quote! { - #![cfg_attr(feature = "rt", feature(asm))] - #![cfg_attr(feature = "rt", feature(core_intrinsics))] + #![cfg_attr(feature = "rt", feature(global_asm))] #![cfg_attr(feature = "rt", feature(linkage))] #![cfg_attr(feature = "rt", feature(macro_reexport))] - #![cfg_attr(feature = "rt", feature(naked_functions))] #![cfg_attr(feature = "rt", feature(used))] }); } @@ -234,24 +232,24 @@ pub fn interrupt( names.push(name_uc); } + let aliases = names.iter() + .map(|n| format!(" +.weak {0} +{0} = DEFAULT_HANDLER", n)) + .collect::>() + .concat(); + let n = util::unsuffixed(u64(pos)); match *target { Target::CortexM => { mod_items.push(quote! { - #( - #[allow(non_snake_case)] - #[allow(private_no_mangle_fns)] - #[cfg(feature = "rt")] - #[linkage = "weak"] - #[naked] - #[no_mangle] - extern "C" fn #names() { - unsafe { - asm!("b DEFAULT_HANDLER" :::: "volatile"); - ::core::intrinsics::unreachable() - } - } - )* + #[cfg(feature = "rt")] + global_asm!(#aliases); + + #[cfg(feature = "rt")] + extern "C" { + #(fn #names();)* + } #[allow(private_no_mangle_statics)] #[cfg(feature = "rt")] @@ -259,27 +257,20 @@ pub fn interrupt( #[link_section = ".vector_table.interrupts"] #[no_mangle] #[used] - pub static INTERRUPTS: [Option; #n] = [ + pub static INTERRUPTS: [Option; #n] = [ #(#elements,)* ]; }); } Target::Msp430 => { mod_items.push(quote! { - #( - #[allow(non_snake_case)] - #[allow(private_no_mangle_fns)] - #[cfg(feature = "rt")] - #[linkage = "weak"] - #[naked] - #[no_mangle] - extern "msp430-interrupt" fn #names() { - unsafe { - asm!("jmp DEFAULT_HANDLER" :::: "volatile"); - ::core::intrinsics::unreachable() - } - } - )* + #[cfg(feature = "rt")] + global_asm!(#aliases); + + #[cfg(feature = "rt")] + extern "msp430-interrupt" { + #(fn #names();)* + } #[allow(private_no_mangle_statics)] #[cfg(feature = "rt")] @@ -288,7 +279,7 @@ pub fn interrupt( #[no_mangle] #[used] pub static INTERRUPTS: - [Option; #n] = [ + [Option; #n] = [ #(#elements,)* ]; }); From b84f13af6f4e8c743909b6d4ca1a2d91fdae7a26 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Fri, 21 Jul 2017 20:35:35 -0500 Subject: [PATCH 2/2] work around AppVeyor issues --- appveyor.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 507fa833..8505372e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,6 +2,10 @@ environment: global: CRATE_NAME: svd2rust RUST_VERSION: stable + # workaround for AppVeyor issues (2017-07-21) + RUSTUP_USE_HYPER: 1 + CARGO_HTTP_CHECK_REVOKE: false + matrix: # MinGW