9adcbac30d
If a static is flagged as address_insignificant, then for LLVM to actually perform the relevant optimization it must have an internal linkage type. What this means, though, is that the static will not be available to other crates. Hence, if you have a generic function with an inner static, it will fail to link when built as a library because other crates will attempt to use the inner static externally. This gets around the issue by inlining the static into the metadata. The same relevant optimization is then applied separately in the external crate. What this ends up meaning is that all statics tagged with #[address_insignificant] will appear at most once per crate (by value), but they could appear in multiple crates. This should be the last blocker for using format! ...
20 lines
594 B
Rust
20 lines
594 B
Rust
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
|
// file at the top-level directory of this distribution and at
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
// option. This file may not be copied, modified, or distributed
|
|
// except according to those terms.
|
|
|
|
pub fn foo<T>() -> int {
|
|
#[address_insignificant]
|
|
static a: int = 3;
|
|
a
|
|
}
|
|
|
|
pub fn bar() -> int {
|
|
foo::<int>()
|
|
}
|