麻烦通过pragma禁用LLVM优化 [英] Trouble disabling LLVM optimizations via pragma

查看:783
本文介绍了麻烦通过pragma禁用LLVM优化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一大堆代码崩溃,除非我用优化关闭。我正在使用LLVM编译器2.0构建

I have a chunk of code that crashes unless I build with optimizations off. I'm building with LLVM compiler 2.0

我想关闭优化,通过使用#pragma编译器指令包装违规代码;或关闭整个文件的优化。

I would like to turn off optimizations by wrapping the offending code with a #pragma compiler directive; or turn off optimizations for an entire file.

我一直在挖掘clang手册和代码;

I've been digging in the clang manual and code; but nothing jumps out at me.

有没有人知道如何更改单个CU的优化(而不是整个应用)?

Does anyone know how to change the optimizations for a single CU (as opposed to for the entire app)?

推荐答案

您可以在Xcode中设置每个文件的编译器标志。在Xcode 4(我假设你使用的是因为LLVM 2.0引用),首先在左边的项目浏览器中选择项目。转到构建阶段选项卡并展开编译源构建阶段。

You can set per-file compiler flags in Xcode. In Xcode 4 (which I assume you're using because of the LLVM 2.0 reference), first select the project in the left-hand project browser. Go to the Build Phases tab and expand the Compile Sources build phase.

在这里,您可以设置每个文件的编译器标志,因此您可以尝试转到错误的文件并输入 -O0 作为一个标志尝试并禁用该文件的优化。

In there, you can set per-file compiler flags, so you could try going to the offending file and entering in -O0 as a flag to try and disable optimizations for just that file.

GCC有一些属性,你可以为此设置,如Johannes在他的答案在这里,但这些可能不是在LLVM。此外,从评论中,似乎这些甚至在苹果的定制GCC用于构建iOS应用程序。

GCC has some attributes you can set for this, as pointed out by Johannes in his answer here, but these might not be in LLVM. Also, from the comments there, it appears that these are not even in Apple's customized GCC used for building iOS applications.

这篇关于麻烦通过pragma禁用LLVM优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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