Is it possible to generate build.ninja for Linux kernel? - linux-kernel

I have been using ninja build for some projects. And it is very convenient to generate a compilation database file with ninja -t compdb. This file can be used in Visual Studio Code for accurate symbol resolution.
So is it possible to generate a build.ninja and then the compilation database for the Linux kernel?
ADD 1 - 6:54 PM 12/5/2021
I did some search and found some related links. Just note them here for now.
https://dev.to/wataash/create-compilation-database-compilecommandsjson-for-netbsd-kernel-source-3c3n
https://github.com/vitkyrka/kninja

Related

Instrumenting a Rust executable for profiling

I'm trying to analyze the performance of a Rust executable on Windows, but cannot seem to instrument the executable image using the VSInstr.exe tool.
To get started I set up a binary cargo package (cargo new --bin sample), and enabled generation of a PDB by adding
[profile.release]
debug = true
to the standard Cargo.toml file. Executing cargo build --release produces both sample.exe and sample.pdb. Navigating to target/release and executing vsinstr sample.exe produces the following diagnostic (VS2017 and VS2019, respectively):
Error VSP1011: Unable to obtain debug information. Link with the /Profile linker switch.
Unable to obtain debug information. Link with the /PROFILE linker switch.
Fair enough, so let's add the following .cargo/config file:
[build]
rustflags = ["-C", "link-args=/PROFILE"]
to pass the required flag to the linker. Running cargo build --release again produces the same artifacts, sample.exe and sample.pdb. Attempting to instrument the image using vsinstr sample.exe now produces the following diagnostic (VS2017 and VS2019, respectively):
Error VSP1033: The file '<path>\sample.exe' does not contain a recognized executable image.
The file does not contain a recognized executable image.
I'm not sure how to proceed from here, or how to further diagnose the core issue.
Is there something wrong with what I'm doing?
Am I running into a limitation of rustc/Clang?
Most importantly, how do I fix the issue?
Notes:
The /PROFILE linker option is documented to be "available only in Enterprise (team development) versions". That information seems outdated. Using the option on a C++ application in Visual Studio 2019 Community had the desired effect.
I've verified, that the /PROFILE flag gets passed to the linker by adding the -Z print-link-args flag to the rustflags in .cargo/config to see the actual linker command line.
Profiling any given Rust application in sample mode (CPU Usage) from the Visual Studio IDE works as long as the respective PDB is available. That's helpful, but I'd really like to get accurate call graphs, so instrumentation is required.
Alongside VSInstr.exe, Visual Studio also ships a binary called vsinstr.legacy.exe, that apparently dumps out more information. Running this against the Rust executable produces a list of warnings that have the following shape:
Warning VSP2005: Internal instrumentation warning: Block start at 1400016D9 is inside instruction at 1400016D8. Removed.
The addresses in all messages differ exactly by 1, which looks an awful lot like an off-by-one error, presumably in the code that produces the PDBs.

building cmake from source for Visual Studio 2019

I get the following error, if trying to build cmake 3.18 from https://github.com/microsoft/CMake.
gmake: *** No rule to make target '/home/ubuntu/Projects/CMake/Source/cmStringTable.cxx'
The file by the way is not in any of the folders.
The system is ubuntu arm64.
It is said that this version must be used because of the activated CMake Server mode.
I can build cmake from kitware on the same machine without problems.
This is a known issue with Mircosoft's fork: https://github.com/microsoft/CMake/issues/90
User "tinco" writes:
I fixed it for myself by not using bootstrap and instead using cmake to compile itself.
I think the fix for this is to remove mention of cmStringTable from the bootstrap script. A more complete fix would be to have the bootstrap script generate the components instead of having them hardcoded.
So you should use your system CMake to build Microsoft's fork instead of using their bootstrap script.
It is said that this version must be used because of the activated CMake Server mode.
I wonder, though, who says this? The CMake Server mode was deprecated a while ago. Microsoft releases its own binaries as part of Visual Studio 2019's CMake tools for Windows. I am curious why you want to use this fork on Linux, rather than the upstream version.

Perl6 NativeCall cannot locate symbol in native library

I have a module using NativeCall that works on both Linux and macOS, but not Windows. When I try to use the module on Windows I get lots of errors like:
# Cannot locate symbol 'TinyTIFFReader_open' in native library 'tinytiff.dll'
I use cmake for my C++ dependency on all three OS's. On Linux and macOS I can just cmake ..; make; sudo make install, and on Windows I cmake -G "Visual Studio 15 2017 Win64" .. and then open the created ".sln" in Visual Studio to compile. The build succeeds with no errors on all three OS's.
Does anyone have any ideas of what I would need to do/change to also get my module working on Windows?
The full module is located here: https://github.com/ryn1x/Graphics-TinyTIFF
I think you will have to give TINYTIFFREADER_LIB_EXPORT and TINYTIFFWRITER_LIB_EXPORT defines a value (either in the source, but probably better to have it be passed by the build system) and on windows i think it has to be __declspec(dllexport), otherwise the symbols may not be made available in the dll.

Use HDF5 from intel fortran on windows

I would like to create a HDF5 dataset from a fortran90 program compiled with intel fortran 2011 on Windows 7 using Visual Studio 2010
Can I use prebuilt binaries or how do I build new ones
I build from source, the available built binaries use the MS C/C++ compiler while I want to build with the Intel compiler, and they are built with Intel Fortran v12.x while I'm using v14.x. I won't say that you can't use the binaries, but I've had enough of a struggle in the past to persuade me to build my own.
I've also had struggles with trying to build them directly from VS and now use CMake. Your first step ought to be to install CMake and figure out how to use it. You don't need much knowledge of the tool and the effort will be repaid several times over. You can, for example, also use CMake to build Szip and Zlib, if you want them. An increasing amount of this sort of software is made available with CMake support so you won't necessarily only use it for HDF5. For example, I use CMake to build VTK for Windows too.
Once you've done that and generated the solution/project files with CMake you can load up the solution in VS and build ALL_BUILD. This generally works smoothly, though I have found that some projects need to have their linkages adjusted and sometimes I get spurious flags in the command-lines sent to the compilers. Then, running VS in administrator mode, you can build the pseudo-target INSTALL.
I see that HDF5 1.8.12 is now available, I'll download and build it, let you know how I get on.
Compiling and Linking
If you just want to use HDF5 include the line
USE, NON_INTRINSIC :: hdf5
at the appropriate place in your source file(s). Then, under Project Properties | Fortran | General | Additional Include Directories insert the path to the location of hdf5.mod. That should get you compiling.
To link, under Project | Properties | Linker | General | Additional Library Directories insert the path the location of the .lib files. Then, under Project | Properties | Linker | Input | Additional Dependencies insert hdf5_fortran.lib.
You should then be able to compile and link your program. If you want to use additional facilities, such as the HDF5 Table Interface, then use h5tb and figure out the linkages.
And consult the documentation. See, for example, ../HDF5-1.8.12/release_docs/USING_HDF5_VS.txt
I succeeded thanks to High Performance Mark:
Here was what I did (not sure that everything is necessary):
Download and install cmake
Download and install HDF5 [Windows (32-bit), Compilers: CMake VS 2010 C, C++, IVF 12, RWDI]
Set environment variable: HDF5_DIR=C:/Program Files/HDF_Group/HDF5/1.8.x/cmake/hdf5
Download HDF5 source
Make empty build folder
Run CMake(cmake-gui) from start menu
Set source (HDF5 source) and destination (empty build folder)
Configure
Set generator to Visual Studio 10
Specify native compilers [C:"", C++:"", Fortran: "<..>\ifort.exe"]
Check: BUILD_SHARED_LIBS and HDF5_BUILD_FORTRAN
Configure
Configure
Generate
Open <..>\build\HDF5.sln in Visual Studio 2010
build project ALL_BUILD
And finally
Create new project with a Fortran example
Linked the generated libs exactly as High Performance Mark describes
I hope some else can use the reciepe.
Thanks again

How to import opencv libraries into eclipse using windows

i'm trying to import that libraries into eclipse using that tutorial. But i retrieve that error:
**** Build of configuration Debug for project OpenCVExample****
**** Internal Builder is used for build ****
gcc -IC:\OpenCV2.1\include\ -O0 -Wall -o src\example.o ..\src\example.c
Build error occurred, build is stopped
Time consumed: 68 ms.
What can i do? i follow all the tutorial line by line, can someone help me? Thanks!
The error message doesn't say what the error was, it just says that there was a problem.
Looking at the tutorial I can say there is one obvious error: while the tutorial assumes you installed v2.1, it gives you the link to download and install v2.2 (OpenCV-2.2.0-win32-vs2010.exe).
So one thing you need to pay attention is: if the version you installed is different from the one used in that tutorial, you need to take this into consideration when adjusting:
The environment variable PATH;
The directory name in C/C++ Build -> Setting -> GCC C++ Compiler -> Directories;
And the name of the libraries in MinGW C++ Linker -> Libraries.
For instance, the library names for v2.1 are:
cv210
highgui210
cxcore210
cvaux210
cxts210
ml210
opencv_ffmpeg210
But if you are using v2.2, you need to use:
cv220
highgui220
cxcore220
cvaux220
cxts220
ml220
opencv_ffmpeg220
Capiche?
Now, if you continue to have problems you can consider installing Visual Studio 2010 Express, which you can use and download for free. This post will show you how to configure it for OpenCV.

Resources