mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-11-03 21:25:25 +00:00 
			
		
		
		
	Cofigurate out ohos target to avoid compilation crashes
This commit is contained in:
		
							parent
							
								
									1795a85be3
								
							
						
					
					
						commit
						6d24962cb8
					
				
					 2 changed files with 7 additions and 5 deletions
				
			
		| 
						 | 
					@ -17,7 +17,7 @@ cfg-if = "1.0.0"
 | 
				
			||||||
libc.workspace = true
 | 
					libc.workspace = true
 | 
				
			||||||
jemalloc-ctl = { version = "0.5.0", package = "tikv-jemalloc-ctl", optional = true }
 | 
					jemalloc-ctl = { version = "0.5.0", package = "tikv-jemalloc-ctl", optional = true }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[target.'cfg(target_os = "linux")'.dependencies]
 | 
					[target.'cfg(all(target_os = "linux", not(target_env = "ohos")))'.dependencies]
 | 
				
			||||||
perf-event = "=0.4.7"
 | 
					perf-event = "=0.4.7"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[target.'cfg(windows)'.dependencies]
 | 
					[target.'cfg(windows)'.dependencies]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,7 @@ use crate::MemoryUsage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub struct StopWatch {
 | 
					pub struct StopWatch {
 | 
				
			||||||
    time: Instant,
 | 
					    time: Instant,
 | 
				
			||||||
    #[cfg(target_os = "linux")]
 | 
					    #[cfg(all(target_os = "linux", not(target_env = "ohos")))]
 | 
				
			||||||
    counter: Option<perf_event::Counter>,
 | 
					    counter: Option<perf_event::Counter>,
 | 
				
			||||||
    memory: MemoryUsage,
 | 
					    memory: MemoryUsage,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -24,7 +24,7 @@ pub struct StopWatchSpan {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl StopWatch {
 | 
					impl StopWatch {
 | 
				
			||||||
    pub fn start() -> StopWatch {
 | 
					    pub fn start() -> StopWatch {
 | 
				
			||||||
        #[cfg(target_os = "linux")]
 | 
					        #[cfg(all(target_os = "linux", not(target_env = "ohos")))]
 | 
				
			||||||
        let counter = {
 | 
					        let counter = {
 | 
				
			||||||
            // When debugging rust-analyzer using rr, the perf-related syscalls cause it to abort.
 | 
					            // When debugging rust-analyzer using rr, the perf-related syscalls cause it to abort.
 | 
				
			||||||
            // We allow disabling perf by setting the env var `RA_DISABLE_PERF`.
 | 
					            // We allow disabling perf by setting the env var `RA_DISABLE_PERF`.
 | 
				
			||||||
| 
						 | 
					@ -51,7 +51,7 @@ impl StopWatch {
 | 
				
			||||||
        let time = Instant::now();
 | 
					        let time = Instant::now();
 | 
				
			||||||
        StopWatch {
 | 
					        StopWatch {
 | 
				
			||||||
            time,
 | 
					            time,
 | 
				
			||||||
            #[cfg(target_os = "linux")]
 | 
					            #[cfg(all(target_os = "linux", not(target_env = "ohos")))]
 | 
				
			||||||
            counter,
 | 
					            counter,
 | 
				
			||||||
            memory,
 | 
					            memory,
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -60,10 +60,12 @@ impl StopWatch {
 | 
				
			||||||
    pub fn elapsed(&mut self) -> StopWatchSpan {
 | 
					    pub fn elapsed(&mut self) -> StopWatchSpan {
 | 
				
			||||||
        let time = self.time.elapsed();
 | 
					        let time = self.time.elapsed();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #[cfg(target_os = "linux")]
 | 
					        #[cfg(all(target_os = "linux", not(target_env = "ohos")))]
 | 
				
			||||||
        let instructions = self.counter.as_mut().and_then(|it| {
 | 
					        let instructions = self.counter.as_mut().and_then(|it| {
 | 
				
			||||||
            it.read().map_err(|err| eprintln!("Failed to read perf counter: {err}")).ok()
 | 
					            it.read().map_err(|err| eprintln!("Failed to read perf counter: {err}")).ok()
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					        #[cfg(all(target_os = "linux", target_env = "ohos"))]
 | 
				
			||||||
 | 
					        let instructions = None;
 | 
				
			||||||
        #[cfg(not(target_os = "linux"))]
 | 
					        #[cfg(not(target_os = "linux"))]
 | 
				
			||||||
        let instructions = None;
 | 
					        let instructions = None;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue