Skip to content

Instantly share code, notes, and snippets.

View alexandrumc's full-sized avatar
🎯
Focusing

Alexandru Militaru alexandrumc

🎯
Focusing
  • Bucharest, Romania
View GitHub Profile
@alexandrumc
alexandrumc / compiletime.sh
Last active April 18, 2020 07:02
Script for measuring compile-time variations of DMD
#!/bin/bash
touchfiles="
touch $HOME/.dub/packages/phobos-master/phobos/std/file.d
touch $HOME/.dub/packages/mir-optim-1.5.1/mir-optim/source/mir/optim/least_squares.d
touch $HOME/.dub/packages/mir-cpuid-1.2.2/mir-cpuid/source/cpuid/x86_any.d
touch $HOME/.dub/packages/mir-core-1.0.3/mir-core/source/mir/conv.d
touch $HOME/.dub/packages/mir-3.2.0/mir/source/mir/model/lda/hoffman.d
@alexandrumc
alexandrumc / x.d
Last active December 19, 2019 14:45
DLang - semantic analysis on imports
module x;
import y;
/*
Semantic analysis 1 = only TOP-LEVEL declarations are analyzed
By TOP-LEVEL declarations I understand: - functions (the header of the function, the parameters and the return type;
*the body IS NOT included*)
- global variables (templates instantiations included)
- struct/classes/templates declarations
@alexandrumc
alexandrumc / descr.md
Last active December 11, 2019 14:57
Solving unittest issue

Now let's see how the previous example correlates with compilation taking longer when using -unittest.

Besides the if(compiledWithUnittest) block from the needsCodegen() which prefers instantiations from root modules, there's another if(compiledWithUnittest) which enforces the treatment of non-root modules (imports) as root modules.

for reference: https://github.com/dlang/dmd/blob/f5f0b68b8537270fd70cb7fb27c703abd216377d/src/dmd/dtemplate.d#L7139-L7144

This means that if you have the following program:

module test;
TWO ways: 1) dmd importer.d
2) dmd -unittest importer.d
import importme; // *importme.d* is opened and semantic analysis on *importme.d* begins;
// now you should follow the comments from *importme.d*
//imports are solved now; semantic analysis continues
void main()
{
@alexandrumc
alexandrumc / dsrc.md
Created May 20, 2019 13:10
Dlang - Bitfields templates introduces useless GOT
import std.bitmanip;

struct MyStruct
{
    mixin(bitfields!(
        uint, "x", 2,
        uint, "", 6));

}
@alexandrumc
alexandrumc / gcc_flags.md
Last active May 20, 2019 11:30
How virtio_net.c is compiled in Linux kernel
gcc -Wp,-MD,drivers/net/.virtio_net_tmp.mod.o.d  
	-nostdinc 
	-isystem /usr/lib/gcc/x86_64-linux-gnu/7/include -I./arch/x86/include -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi 
	-I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h 
	-D__KERNEL__ -Wall -Wundef 
	-Wstrict-prototypes -Wno-trigraphs 
	-fno-strict-aliasing -fno-common -fshort-wchar 
	-Werror-implicit-function-declaration -Wno-format-security 
	-std=gnu89