Closed Riateche closed 4 years ago
Original pull request to qt_build_tools
old repo contained these changes to src/lib.rs
:
self.add_cpp_data_filter(Box::new(move |cpp_data| {
fix_header_names::fix_header_names(cpp_data, &qt_this_lib_headers_dir)
}));
- self.add_cpp_parser_flags(vec!["-fPIC", "-fcxx-exceptions"]);
+ self.add_cpp_parser_flag("-fcxx-exceptions");
if cpp_to_rust::utils::is_msvc() {
self.add_cpp_parser_flag("-std=c++14");
} else {
- self.add_cpp_parser_flag("-std=gnu++11");
+ self.add_cpp_parser_flags(vec!["-fPIC", "-std=gnu++11"]);
self.add_cpp_compiler_flags(vec!["-fPIC", "-std=gnu++11"]);
}
self.add_cpp_parser_blocked_name("qt_check_for_QGADGET_macro");
Thanks for the pull request!
First of all, there have been some big architecture changes in cpp_to_rust
. All code now lives in this repository, and all issues and pull requests should go there. I'm going to delete all outdated repositories when possible.
The main change related to this issue is that clang parser now only runs once when the crate is generated, and the result is used on all supported platforms without re-running the generator. So now it should be possible to run the parser on Linux and use the generated crate on Windows.
Nevertheless, the issue is still important because it should be possible to run the parser on Windows. My installation of clang and Appveyor's installation (see build log here, for example) clearly accept -fPIC
argument. And IIRC it doesn't work without -fPIC
, so I put it there deliberately. What is your version of clang and how was it built/installed? My best guess is that the behavior depends on the clang's target, but that would mean that Appveyor's clang doesn't use msvc target, which is already bad enough. We need to investigate it.
Copied from original pull request
It looks like clang 3.8 accepted -fPIC
flag.
This code allowed to build compilable qt libraries on Linux with clang 3.9.1:
cpp_to_rust/cpp_to_rust_generator/src/cpp_parser.rs
TypeKind::Elaborated => {
let canonical = type1.get_canonical_type();
if canonical.get_kind() != TypeKind::Elaborated {
self.parse_type(canonical, context_class, context_method)
} else {
Err(format!("Elaborated type: {:?}. Canonical: {:?}", type1, canonical).into())
}
}
_ => Err(format!("Unsupported kind of type: {:?}. {:?}", type1.get_kind(), type1).into()),
Same issue with -fPIC
with clang 5.0.0. What if test clang version on windows or add command line option?
Running `target\release\qt_generator.exe -c D:\devel\qt-cache -C 3 -l core
--debug-logging save -o D:\devel\qt-rust-test01\`
Preparing generator config for library: core
Executing command: "qmake" "-query" "QT_VERSION"
QT_VERSION = "5.7.1"
Detecting Qt directories
Executing command: "qmake" "-query" "QT_INSTALL_HEADERS"
QT_INSTALL_HEADERS = "D:/Qt/Qt5.7.1/5.7/msvc2015_64/include"
Executing command: "qmake" "-query" "QT_INSTALL_LIBS"
QT_INSTALL_LIBS = "D:/Qt/Qt5.7.1/5.7/msvc2015_64/lib"
Executing command: "qmake" "-query" "QT_INSTALL_DOCS"
QT_INSTALL_DOCS = "D:/Qt/Qt5.7.1/Docs/Qt-5.7"
Output Cargo.toml file will contain local paths of used dependencies (use --no-l
ocal-paths to disable).
Generating crate: qt_core
Running C++ parser
clang version 5.0.0 (tags/RELEASE_500/final)
Initializing clang...
Warning: CLANG_SYSTEM_INCLUDE_PATH environment variable is not set.
This may result in parse errors related to system header includes.
clang arguments: ["-Xclang", "-detailed-preprocessing-record", "-fPIC", "-fcxx-e
xceptions", "-std=c++14", "-I", "D:/Qt/Qt5.7.1/5.7/msvc2015_64/include", "-I", "
D:/Qt/Qt5.7.1/5.7/msvc2015_64/include\\QtCore"]
Error:
0: fatal clang error:
error: unsupported option '-fPIC' for target 'x86_64-pc-windows-msvc'
1: C++ parser failed
error: process didn't exit successfully: `target\release\qt_generator.exe -c D:\
devel\qt-cache -C 3 -l core --debug-logging save -o D:\devel\qt-rust-test01\` (e
xit code: 1)
clang version 5.0.0 (tags/RELEASE_500/final)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin
It seems that support of -fPIC option depends on either clang version or its target (I'm not sure but I think you can have clang for different platforms on Windows, just like Rust). I can see three solutions here:
Should be fixed now.
From @o01eg on April 25, 2017 12:47
When I try to build Qt application on windows I get error:
rust version:
clang version:
_Copied from original issue: rust-qt/qtcore#2