With Visual Studio under Windows, it is possible to delay load libraries and functions, with the linking flag "/DelayLoad somelib.lib", something provided by DelayImp.lib.
Under the hood, it seems that doing so tells the linker to wrap every referenced function of "somelib.lib" with the Win32 APIs LoadLibrary and GetProcAddress, which allows to resolve the functions at runtime.
I would need to accomplish the same with clang under Windows, but didn't manage to find any documentation on the subject.
It is possible to delay load libraries with clang / LLVM, and if so, how?
For the curious, this is part of an on-going project to port meterpreter's codebase to clang, which relies heavily on said delay loading offered by MSVC.
Related
I've been working with a teensy for a multithreaded project using openmp compiling with gcc, however I'm joining a project that uses avr-gcc which doesn't seem to want to compile or recognize omp.h . I get the error "avr-gcc: error: unrecognized command line option '-pthread' " when I attempt to compile and am having trouble finding more information. I found this question about gcc-avr having slower updates AVR gcc version < gcc release versions -- why? but am wondering if avr-gcc hasn't yet added openmp support or doesn't for one reason or another and if there's a work around without requiring the team to switch compilers.
thanks for the direction it appears that avr-gcc doesn't provide headers that interact with operating systems which apparently pthreads does.
"Since sockets are a feature provided by the operating system, and you are compiling code that runs bare-metal on an Arduino microcontroller, which has no operating system running on top, the whole purpose of the sys/socket.h header is nullified.
This applies to any other kind of header or library function that interacts with the operating system, such as unistd.h, fcntl.h, pthread.h etc. In fact, avr-libc, the Standard C library for AVR-GCC, does not provide such headers.
You will need to look at the avr-libc documentation to find out more about the headers and functions that are provided and their usage."
I know both clang (by use target=wasm32) and emscripten can compile C code into webassembly, but how are they different?
It looks like they both use LLVM as backend. Actually, I do not even quite understand the relation between llvm and clang...
I have been reading WebAssembly for a while, but I lack low-level understanding of it. Thank you so much for your time!!
clang is a compiler built on llvm technology so you often hear clang and llvm used interchangeably. clang is a just one component of the llvm project.
emscripten is a compiler that uses clang for most of the heavy lifting of actually compiling to WebAssembly but also add a lot of features and functionality on top of that, mostly related to seamless integration with JavaScript and the web and emulation of POSIX and other standards.
emscripten runs clang internally with --target=wasm32-unknown-emscripten which has some very minor differences to the regular --target=wasm32.
If you run emscripten with -v it will print the full clang command line its uses under the hood.
I'm trying to add lua static library onto my project using CMAKE. But what I found from lua documents that they have several version of Visual Studio libraries for 32/64-bit architecture.
I need to learn is there a option on CMAKE to identify the architecture and generator used for generating required files.
Thanks in advance
There's a host of system inspection variables and information variables which CMake offers. I'll try to list some which might be applicable in your case:
CMAKE_CL_64: true if the compiler being used is Microsoft's CL targetting a 64-bit architecture
MSVC: true if using a Miscrosoft Visual C++ compiler
CMAKE_GENERATOR: the generator being used
CMAKE_GENERATOR_PLATFORM: generator-specific target platform name
CMAKE_SIZEOF_VOID_P: size of void*, in bytes
You should also be aware that CMake ships with a FindLua module, so you might find the decision already implemented for you in that module. (I have never used it myself, so I do not now whether/how it works).
reading this link :http://fdiv.net/2012/08/15/compiling-code-clang-api
i see i can load c/c++ file and compile it just fine to executable..
but i did't found any info if i have some kind of source code in c/c++
that my application generating or other way ..
in short can i pass the stage where i load the c file , and just build my own logic to compile to executable ?
Of course you can. And there is already a project for that purpose
Dig its source codes as your wish :)
Cling
What is Cling
Cling is an interactive C++ interpreter, built on the top of
LLVM and Clang libraries. Its advantages over the standard
interpreters are that it has command line prompt and uses
just-in-time (JIT) compiler for compilation. Many of the developers
(e.g. Mono in their project called CSharpRepl) of such kind
of software applications name them interactive compilers.
One of Cling's main goals is to provide contemporary, high-performance
alternative of the current C++ interpreter in the ROOT project -
CINT. The backward-compatibility with CINT is major priority during
the development.
I've been searching around the Lazarus IDE documentation for a bit, and thus far only found information related to cross compiling, so I was hoping someone could give me a straight answer on this. I'm currently working on a project that will require compilation for 32-bit Windows as well as 64-bit Windows. Additionally, I've already set up both versions of the Free Pascal Compiler. Does Lazarus have any built in functionality for configuring in both compilers, and then based on the build target, using the appropriate compiler? Ideally, this would be done at a global level, so that the configuration persists across projects, but if it can only be done at the project level, I don't mind doing it that way.
On further reading, I think I found my answer. I didn't realize it, but fpc has the same sort of front-end functionality as gcc. With that said, implementing the functionality described in my question is just a matter of installing the compiler as a cross compiler, rather than as an independent compiler. Since it doesn't look like you can use the x86_64 compiler to create a 32-bit version, you'll have to compile the 32-bit version, and then crosscompile the 64-bit version. In my case, I first compiled and installed the Win32 compiler using:
make all install INSTALL_PREFIX=C:\path\to\lazarus\1.0.8\fpc\2.6.3 OS_TARGET=win32 CPU_TARGET=i686 PP=ppc386.exe
Next, I compiled and crossinstalled the 64-bit compiler:
make crossall crossinstall INSTALL_PREFIX=C:\path\to\lazarus\1.0.8\fpc\2.6.3 OS_TARGET=win64 CPU_TARGET=x86_64
To confirm that it worked, you can find an executable called, ppcrossx64 in your C:\path\to\lazarus\1.0.8\fpc\2.6.3\bin\i386-win32 folder.