[英]Intel Pin with C++14
我对 Intel Pin 与 C++14 或其他 C++ 版本的使用有一些疑问。
我正在构建一个动态调用图 pin 工具。 为了便于理解,我正在计算调用堆栈的深度。 为了安全起见,我决定用std::mutex
包装增加或减少深度的代码摘录。 这让我想到了std::mutex
仅从 C++11 开始可用的问题,这不是我机器中的 Intel Pin 默认值。
$ 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++ 的命令是
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 个不同的目录中:
/usr/include/c++/5/
/home/gabriel/Downloads/pin-3.0-76991-gcc-linux/extras/stlport/include/
一一解决错误是不可行的,删除 pin stl 端口可能是一个更糟糕的主意。 如果可以将 Pin 与较新的 C++ 一起使用,我会说简单的std=c++1y
不是方法。
从用于编译 pin 工具的编译器选项来看,我假设您使用的是最新版本的 Pin,即 3.0。 据英特尔称,该框架附带的 CRT 不支持该语言的 C++11 和更高版本。 特别是,您将无法使用 C++11 中支持的任何 API,包括std::mutex
。 如果使用 C++11 API 对您很重要,那么您应该使用以前版本的 Pin,即 2.14,它不附带 CRT 并使用编译器的 CRT。
但是,如果您只需要一个互斥锁,则可以使用 Pin 3.0 附带的操作系统可移植互斥锁。 有关更多信息,请参阅文档。
使用 Pin 3.0 时,不允许使用编译器的任何头文件或目标文件(来自/usr/include/c++/5/
)。 您只能使用 PinCRT 和很少的系统头文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.