带有C ++ 14的英特尔针 [英] Intel Pin with C++14

查看:83
本文介绍了带有C ++ 14的英特尔针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于在C ++ 14或其他C ++版本上使用Intel Pin的问题,我有几个问题.

I have a few questions surrounding usage of Intel Pin with C++14 or other C++ verions.

  • 从旧版C ++更新版本中编译代码几乎没有问题,但是由于Intel Pin是操纵指令级的,所以如果我用C ++ 11或C ++ 14进行编译,是否会产生不良后果?
  • 如果可以使用C ++ 11或C ++ 14进行编译,如何制定规则以仅对我的工具启用较新版本的C ++?
  • 如果可能,如何将GCC/G ++默认C ++版本设置为最新版本, ?这样做时应注意什么?
  • There are rarely any problems compiling code from older C++ with newer versions, but since Intel Pin is manipulates instruction level, is there any undesirable side effects that might come if I compile it with C++11 or C++14?
  • If it's ok to compile with C++11 or C++14, how do I make a rule to enable a newer version of C++ for my tool only?
  • How do I set GCC/G++ default C++ version to latest, if possible, and what should I keep in mind when doing so?

我正在构建一个动态调用图图钉工具.为了使其易于理解,我正在计算调用堆栈的深度.为了安全起见,我决定用std::mutex包装用于增加或减少深度的代码摘录.这使我想到了std::mutex仅从C ++ 11开始可用的问题,这不是我机器上的Intel Pin默认值.

I'm building a dynamic call graph pin tool. To make it understandable, I'm computing the depth of the call stack. For safety, I decided to wrap the excerpt of code that increments or decrements the depth with a std::mutex. This has gotten me to the problem that std::mutex is available only since C++11, which is not Intel Pin default in my machine.

$ g++ -v
[...]
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.2)

编译命令:

$ make obj-intel64/callgraph.so
[...]
error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support
[...]

编辑

我设法制定了一个将版本定义为C ++ 11的构建规则,但是该规则会中断.通过make发送到g ++的命令是

EDIT

I managed to make a build rule that defines version to C++11, but it breaks. The command sent to g++ through make was

g++ -DBIGARRAY_MULTIPLIER=1 -Wall -Werror -Wno-unknown-pragmas -D__PIN__=1
-DPIN_CRT=1 -fno-stack-protector -fno-exceptions -funwind-tables
-fasynchronous-unwind-tables -fno-rtti -DTARGET_IA32E -DHOST_IA32E -fPIC
-DTARGET_LINUX -fabi-version=2  -I/home/gabriel/Downloads/pin-3.0-76991-gcc-linux/source/include/pin
-I/home/gabriel/Downloads/pin-3.0-76991-gcc-linux/source/include/pin/gen
-isystem /home/gabriel/Downloads/pin-3.0-76991-gcc-linux/extras/stlport/include
-isystem /home/gabriel/Downloads/pin-3.0-76991-gcc-linux/extras/libstdc++/include
-isystem /home/gabriel/Downloads/pin-3.0-76991-gcc-linux/extras/crt/include
-isystem /home/gabriel/Downloads/pin-3.0-76991-gcc-linux/extras/crt/include/arch-x86_64
-isystem /home/gabriel/Downloads/pin-3.0-76991-gcc-linux/extras/crt/include/kernel/uapi
-isystem /home/gabriel/Downloads/pin-3.0-76991-gcc-linux/extras/crt/include/kernel/uapi/asm-x86
-I/home/gabriel/Downloads/pin-3.0-76991-gcc-linux/extras/components/include
-I/home/gabriel/Downloads/pin-3.0-76991-gcc-linux/extras/xed-intel64/include
-I/home/gabriel/Downloads/pin-3.0-76991-gcc-linux/source/tools/InstLib -O3
-fomit-frame-pointer -fno-strict-aliasing  -std=c++11 
-c -o obj-intel64/callgraph.o callgraph.cpp

这不能编译.相反,它将陷入STL标头中的巨大错误日志中.似乎Pin附带了它自己的STL子集,与C ++ 11和C ++ 14冲突.我已经上传了g ++输出的粘贴.它填满了2331行,但我注意到它访问的文件夹中有一个奇怪的东西. STL库包含在 2 个不同的目录中:

This doesn't compile. Instead, it'll fall into a huge error log inside STL headers. It appears that Pin comes along with it's own subset of STL, that conflicts with C++11 and C++14. I've uploaded a paste of the g++ output. It filled 2331 lines, but I've noticed that strange thing in the folders it visits. STL libraries are included from 2 different directories:

  • /usr/include/c++/5/
  • /home/gabriel/Downloads/pin-3.0-76991-gcc-linux/extras/stlport/include/
  • /usr/include/c++/5/
  • /home/gabriel/Downloads/pin-3.0-76991-gcc-linux/extras/stlport/include/

一个接一个地解决错误是不可行的,删除pin stl端口可能是一个更糟糕的主意.如果可以在更新的C ++中使用Pin,那么我想说简单的std=c++1y不是这样.

Solving errors one-by-one is unfeasible, deleting pin stl port probably is an even worse idea. If it's possible to use Pin with newer C++, I'd say simple std=c++1y is not the way.

推荐答案

从用于编译pin工具的编译器选项中,我假设您使用的是Pin的最新版本,即3.0.根据 Intel ,该框架附带的CRT不能支持C ++ 11和更高版本的语言.特别是,您将不能使用C ++ 11支持的任何API,包括std::mutex.如果对使用C ++ 11 API至关重要,则应使用Pin的早期版本,即2.14,该版本不随CRT一起提供,而是使用编译器的CRT.

From the compiler options used to compile the pin tool, I presume you are using the latest version of Pin, namely 3.0. According to Intel, the CRT that ships with the framework doesn't support C++11 and later versions of the language. In particular, you will not be able to use any of the APIs supported in C++11 including std::mutex. If it's critical for you to use C++11 APIs then you should use the previous version of Pin, namely 2.14, which doesn't ship with a CRT and uses the CRT of your compiler.

但是,如果您只需要一个互斥锁,则可以使用Pin 3.0附带的OS便携式互斥锁.有关更多信息,请参见文档.

However, if all you want is a mutex, you can use the OS-portable mutex that ships with Pin 3.0. For more information, refer to the documentation.

使用Pin 3.0时,不允许使用编译器的任何头文件或目标文件(/usr/include/c++/5/中的文件).您只能使用PinCRT和少量系统头文件.

When using Pin 3.0 you are not allowed to use any header file or object file of your compiler (those from /usr/include/c++/5/). You can only use PinCRT and few system header files.

这篇关于带有C ++ 14的英特尔针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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