编译器优化安全吗? [英] Are compiler optimizations safe?

查看:102
本文介绍了编译器优化安全吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在工作中发现,由于存在编译器错误的风险,因此不对硬实时嵌入式系统使用编译器优化是一项政策(我们主要使用gcc,但该政策也适用于其他编译器)。显然,这项政策之所以开始,是因为过去有人因优化程序的错误而被烧死。我的直觉是,这太过偏执了,所以我开始寻找有关此问题的数据,但问题是我找不到关于此问题的任何硬数据。

I recently discovered at work that it is the policy not to use compiler optimizations for hard real time embedded systems because of the risk of compiler bugs (we mainly use gcc but the policy extends to other compilers as well). Apparently this policy started because someone was burnt in the past by a bug with an optimizer. My gut feeling is that this is being overly paranoid so I've started looking for data on this issue but the problem is I can't find any hard data on this.

有人知道一种实际获取此类数据的方法吗?可以使用gcc bugzilla页面生成一些错误与编译器优化级别的统计信息吗?

Does anyone know of a way to actually get this type of data? Can the gcc bugzilla page be used to generate some statistics of bugs vs compiler optimization level? Is it even possible to get unbiased data like this?

推荐答案

我没有任何数据(并且没有听说过) ....但是...

I don't have any data (and haven't heard of anyone that does ...) but ...

在选择禁用优化之前,我会选择使用哪个编译器。换句话说,我不会使用任何我不相信优化的编译器。

I'd choose which compiler I would use before I'd choose to disable optimizations. In other words, I wouldn't use any compiler I couldn't trust the optimizations on.

Linux内核是使用-Os编译的。比起任何bugzilla分析,这对我来说更具说服力。

The linux kernel is compiled with -Os. That's a lot more convincing to me than any bugzilla analysis.

就我个人而言,任何版本的gcc linux都可以

Personally, I'd be okay with any version of gcc linux is okay with.

作为另一个数据点,苹果公司一直在将gcc转换为llvm(带或不带clang)。传统上,llvm与某些C ++存在问题,而llvm-gcc现在已经好很多了,但clang ++似乎仍然存在问题。但这只是证明了这种模式:虽然苹果(据称)现在使用clang编译OS X和iOS,但如果有的话,它们使用的C ++和Objective C ++并不多。因此,对于纯C和目标C,我会信任clang,但我仍然不信任clang ++。

As another data point, Apple's been converting from gcc to llvm, with and without clang. llvm has traditionally had issues with some C++ and while llvm-gcc is now a lot better, there still seem to be issues with clang++. But that just kind of proves the pattern: while Apple (purportedly) now compiles OS X and iOS with clang, they don't use much if any C++ and Objective C++. So for pure C and Objective C, I'd trust clang, but I still don't yet trust clang++.

这篇关于编译器优化安全吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆