Like programming in C or driving a car, contemporary shellscript languages require some knowledge and discipline to use safely, but that’s not to say it can’t be done.

In the optic to enhance our embedded system’s security, having a compiler plugin feature is fundamental to add new features at compilation time without having to modify the compiler itself (and with minimum knowledge of compiler internals!) This article addresses GCC versions 9 and above on Ubuntu 20.04 LTS. I hope the guide can be enjoyed for other OS/GCC Version.

A pass manager schedules transformation passes and analyses to be run on IR in a specific order. Passes can run on an entire module, a single function, or something more abstract such as a strongly connected component (SCC) in a call graph or a loop inside of a function. Scheduling can be simple, such as running a list of module passes, or running function passes on every function inside a module. Scheduling can also be more involved, such as making sure we visit SCCs in the call graph in the correct order.

A pass manager is also responsible for managing analysis results. Analyses (e.g. dominator tree) should be shared between passes whenever possible for efficiency reasons, since recomputing analyses can be expensive. To do so, the pass manager must cache results and recompute them when they are invalidated by transforms.

For testing purposes, we can add specific passes to a pass manager to test those passes. However, the typical use case is to run a predetermined pass pipeline. For example, clang -O2 runs a predetermined set of passes on the input IR.

Read More

Ohm is a parsing toolkit consisting of a library and a domain-specific language. You can use it to parse custom file formats or quickly build parsers, interpreters, and compilers for programming languages.

The Ohm language is based on parsing expression grammars (PEGs), which are a formal way of describing syntax, similar to regular expressions and context-free grammars. The Ohm library provides a JavaScript interface for creating parsers, interpreters, and more from the grammars you write.

chibicc is yet another small C compiler that implements most C11 features. Even though it still probably falls into the “toy compilers” category just like other small compilers do, chibicc can compile several real-world programs, including Git, SQLite, libpng and chibicc itself, without making modifications to the compiled programs. Generated executables of these programs pass their corresponding test suites. So, chibicc actually supports a wide variety of C11 features and is able to compile hundreds of thousands of lines of real-world C code correctly.

Read More

It seems to be widely accepted that creating a powerful, useful Emacs setup “by hand” is just too much trouble, and you should choose a “distro” like Doom Emacs. But is it really all so bad? If you go the route of “hand-made”, will you suffer through endless nights of fixing your setup? The answer is: probably not, but read on for more details!

The mrsh shell is strictly POSIX compliant, encouraging users to write portable shell scripts. Optional readline/libedit support is included to provide a comfortable interactive shell.

Submodules specifically have managed to be a thorn in my side on many occasions. While the concept of submodules is simple, figuring out how to actually work with them can be a chore. I say “figuring out” because not everything about working with submodules is well documented. I’ll cover two of the more difficult things to figure out: removing and updating submodules from your repository.

This page gives brief, visual reference for the most common commands in git. Once you know a bit about how git works, this site may solidify your understanding. If you’re interested in how this site was created, see my GitHub repository.

Here’s more of what I learned from reading the first part of the fzf README and paying attention. Now I have a better setup and understanding of the basics and how to control the appearance, it’s time to turn my attention to setting some defaults to control what I get in my search results.

In fzf - the basics part 1 - layout I shared what I learned about controlling fzf’s layout. In the examples I showed, based on directories and files in the SAP TechEd 2020 Developer Keynote repository (which I’ll use again in this post), fzf presented a total of over 17000 items from which to make my choice.

That’s a lot, and far more than I want to consider wading through.

Read More

for years nano has been nothing but a mockery for those who use emacs or vim. a friendly and pragmatic editor? what a laughable prospect.

well this is where it ends. nano is a friendly and pragmatic editor, but it’s no notepad. nano has depth. let’s take a look.

This page explains use cases and examples of SSH tunnels while visually presenting the traffic flows. For example, here’s a reverse tunnel that allows only users from IP address access to port 80 on the SSH client through an SSH server.

If you, like me, never really understood Vimscript and hate the language with a passion, you’re in the right place! You can now get rid of Vimscript wholesale and replace it with a simpler, faster and elegant-er language — Lua! However, this is only possible from Neovim 0.5 onwards1 and as of now, requires you to install Neovim from HEAD. How to do that is left as an exercise to the reader. Also bear in mind that the Lua API is fairly beta right now, and many Vim things don’t have direct interfaces.

So assuming you’re now running Neovim master, head over to ~/.config/nvim and create your init.lua. Why, yes, we’re porting over your init.vim to init.lua right now! Clear your calendar for the next few hours — bikeshedding your text editor is top priority!

I also recommend going through nanotee/nvim-lua-guide and Learn Lua in Y minutes before starting off.

Read More

I’ve been working with software for well over a decade, and honestly cannot remember when I started using Git. I used to be a bit wary of many commands but thought I had a good grasp on what to do when it came to git. Then I started a new role at a larger company, which had strict git guidelines. No more messy branches, no crappy commit messages, everything rebased.

Here is a list of all the things I wish I knew before starting this role.

Despite Git being very complicated, for day to day use it is really simple. I tend to make the workflow as simple as possible - I don’t use aliases for git commands, I use the full arguments (–force) instead of the shortened ones (-f).

Read More

In the context of doing less and doing it better I decided to start learning more about fzf, the “command line fuzzy finder”. Learning more wasn’t difficult, because despite using it for quite a while, I’ve never really read any of the documentation, and have thus only scratched its surface.

So I started with the first part of the main README, and here’s what I found.

The examples I give in this post are taken from a directory and file structure reflecting the SAP TechEd 2020 Developer Keynote repository, which has multiple directories and subdirectories, lots of files with different extensions, hidden files and directories (and I’m not just talking about the .git/ directory) and also stuff that we often want excluded, such as any node_modules/ directories. Fairly representative and useful for illustration.

Read More

You want to use Emacs, that is also configured to use some of the coolness of the likes of Doom Emacs, but without bringing in its bloat (i.e., Vanilla Emacs). More importantly, you want to control the specific features configured in your Emacs. And you use NixOS or home-manager (including on macOS). Then this post is for you.

One of the oldest pieces of software still in use was recently described as

A sort of hybrid between Windows Notepad, a monolithic-kernel operating system, and the International Space Station.

Of course, they were talking about Emacs. And yes, it is kinda true.

Programming Tools

This is where all the vim VS emacs posts should go.

Created on Oct 19, 2020
By @gurlic