Skip to main content

Posts

Creating a patch for GNU GCC using Git

Overview and Target Audience The GNU GCC project followed a blend of a traditional method with contemporary git tools when it comes to contributing code, making the experience unique from some other, git-based projects. This blog post will explore different aspects of the process, helpful commands, and various scripts that would make the experience more pleasent for new contributors. While this blog aims to help new contributors get acustomed to the GNU GCC code culture and make contributing easier, it must be stressed that this is not in any way in-depth exploration of the process. This should help you put your first foot forward; the community will help you take the rest of the steps from that point on. This post also assumes the user is in a POSIX environment (e.g. Linux, FreeBSD). Git and GNU As stated in this phoronix post , GNU GCC made a full transition to git early 2020. As of this writing, the community seems to be adjusting to the new tools. GNU GCC hosts its own git serve...

Debugging with GCC: GIMPLE

GCC and GIMPLE One of the very first thing GCC asks the GSoC applicants to do, even before writing the application, is to try various different debugging techniques using GCC. I was personally familiar with the basic, compile-with-g-flag-and-use-gdb method. Turns out, there's more: GIMPLE. A Simple but Non-trivial Program Problem Description The instruction asks to compile a simple but non-trivial program with some flags that generates debugging information: -O3 -S -fdump-tree-all -fdump-ipa-all -fdump-rtl-all . Because I was keep reading on ways to debug GCC just prior to the statement, I immediately thought "GCC" and tried make -j8 CXXFLAGS="-O3 -S -fdump-tree-all -fdump-ipa-all -fdump-rtl-all" . This was a mistake: turns out, GCC can't be compiled with those flags. Thankfully, GCC developers have a very active IRC channel for me to signal SOS. Resolution jakub and segher were quick to respond to my call for help. jakub: it isn't meant that y...

Setting up IRC

About IRC Internet Relay Chat was once the most popular real-time communication method that uses computer for a large spectrum of community groups. While it has largely been supplanted by more contemporarly methods for most people, IRC is still a prefered means of communication among older software projects like GCC. The Client As an old technology that is also very favored among programmers, IRC has many clients with different flavors, from GUI to CLI to headless. As a linux user with strong attraction to tmux, I chose weechat. Depending on your distro or OS, install your client first. Configuring Weechat I will be using GCC channel in OFTC server as the example. How are we configuring this? While Weechat has a configuration file, Weechat officially advises against using the file to configure the program behavior. Instead, it promotes `/set` dialog within the client to set the proper configuration. Connect to server Let's first connect to server. The `#gcc` channel is host...

Act 3 Scene 1

Wait, what? The last post ended with completing Act1 Scene1, with hints to Act1 Scene2. Yeah, a lot happened since. Goblin Camp Some of the last work in the blog was about the Goblin Camp, a revival project of an abandoned source code, which in turn was inspired by a great game, Dwarf Fortress. Since then, I learned more about data structures, and object design patterns. With each enlightenment in programming, I was more and more aware why this code was abandoned multiple times by different groups. I became one of them. This doesn't mean my goal of marrying parallel programming with the great game concept is abandoned: ever since the last communication, I also took a course on GPU programming, and it is giving me new ideas and goals. It just would not be happening with the existing Goblin Camp. More on this in the future. And this concluded my Act 1. How about Act2 My Act 2 began with my Coop placement at Fundserv. It was truly a learning experience, in the best sense of the wor...

Act 1 Scene 1 Exeunt

Act 1 Scene 1 This year, I was able to dabble in open-source for the first time. It was a dream-come-true: a dream I long thought impossible to attain for my lack of understanding in programming language. How far have I changed since: not only is some of my code part of a program used by others, I am also hosting and developing a program as a part of the open-source community. Small, but a community. This all started thanks to DPS909 class . Act 1 Scene 2 The Act is still on. I am just getting warmed up. What will scene 2 have for me in store? Only time will tell. For now, I am going to enjoy cultivating a community while also belonging to many others, finding my way through, contributing as I am able. Perhaps that will be my scene 2. It will be beautifully ugly, and I will love every moment of it. To my audience, even if imaginary If you are reading this and thinking there is nothing you can do to make a meaningful contribution to a program that you love, I am glad to sa...

Project: Boost-free Goblins, part 3

Ready, Aim, and Fire After the battle-cry , and then calming down to make some preparation , I decided to take the shot. The target: boost::shared_ptr. To Action A quick search turns up that shared_ptr is supported in the STL's memory library since c++11. Well, that seems like an easy task. Let's take our script for a spin. tools/boostrm.sh shared_ptr memory Now I have a bunch of std::shared_ptr replacing the boost variant. Seems like everything is in good order. After pushing it into the github to have Travis CI do the honors of compiling it, turns out, some boost::weak_ptr, apparently derived from boost::shared_ptr, was being casted into boost::shared_ptr, and they are not compatible with std::shared_ptr since that's not what they inherited. Well, after a bit of research, it seems the weak_ptr has a STL version. It seems like weak_ptr needs to go, too. tools/boostrm.sh weak_ptr memory After another push into github, and another build run by Travis CI, it tu...

Project: Boost-free Goblins, Part 2

Last time at the goblin_camp The mad developers went on a warpath to rinse away Boost from the goblins. Loud yelling and crying was involved, 52 of them. But now that all the yelling is out of the way, how should we do this? Repetition, repetition, ... I am personally a very lazy programmer. If I can make computer do the job for me, I would have the computer do the job for me. While hunting down every instance of a library manually is doable in small number, as it was for cstdint, Other Boost libraries are more widely used and require much more effort scanning the text. Text. Text. Well, if we are talking about text-manipulation in sh ... Scripting my problem away My beloved hobby tools If it is not apparently already, I love automating tasks, and UNIX shell scripting had been my go-to solution for any binary scripting needs, especially in the days before I learned to program. This problem can be solved quite easily using few lines of scripts. Caveat We will be making a s...

Project: Boost-free goblins

The headache: Boost Don't take me wrongly: Boost library is a powerful set of tools for bleeding-edge technology. Much of it gets absorbed into the C++ Standard Libraries. The problem lies in our project being inactive for 7 years, which means it is relying on a library that is 7 years behind. Installing such an old library is a chore, and securing a pre-built package is problematic at best. The project is even incompatible with the later versions of Boost. It may have once given the original developers a powerful technology to propel their project in the past, but now we are stuck with clock stopped at 2011. Along with libtcod being stuck also in 2012, dealing with Boost is critical to bringing the project up-to-date. Options There are several ways to address the issue. Option 1 : Upgrade We can read each related source code, research how Boost has modified the relevant function calls, and either fix the expected return type or required input type, This may lead to mor...

Vehicles with a Broken Frame

Browsing through github projects in C/C++ Trying to find ways to link up the goblin_camp project with more automated testers, I started looking around the Readme.md files of other C/C++ projects in github. From neovim, I found AppVeyor, and although I have not yet set it up, it promises to supplement Travis CI with Windows test builds. I also found Coverity Scan, which might be a way for us to scan the large, preexisting code and fix goblin_camp. Then, from Cataclysm-DDA, I found Bounty Source . The icon had a dollar figures on it, so I assumed it was some sort of funnily-named fund raising site. It was, but with a twist. Show Me The Money Apparently, this site is designed to help the project by having people put down money into a pot to fix certain issues listed in Github. Some of the issues were very popular: enough people contributed to the pot of 250 dollars. I would also imagine those are tough ones. I found myself a less-popular, 4 year-old issue of 15 dollars . I am mor...

Pick up where others left off

Digging through the dirt My fascination with the Goblin Camp, and by extension Dwarf Fortress, continues. One of the first thing the team did was to implement the initial setup of Travis CI to the repository: I made the issue and linked the account for it, and Robert figured out the configuration file and got it to do something. Our plan is to use this to tell us when, in fact, the game compiles properly. It is spamming me now that the build isn't working, but one day, it is going to show me a green light. The next task was to dust off the 7-year old libraries and implement spanking new ones, starting from Boost. So first, I researched on how boost is included into the repository. There seems to be largely three ways to go about it: system-wide installation, copying over the full source code, and using modular source code. First, just to see if it would work, I replaced the old /vendor/boost folder with the most up-to-date version of full boost. It did not work. Well, it co...

Me and the 7 Dwa.. I mean Goblins

Brief Introduction of the Dwarf Fortress The Dwarf Fortress is a well-established, closed-source, free game that has been continuously developed since 2006. It has inspired some of the most famous games, such as Minecraft. It is considered a rouge-like game, and it chiefly relies on ASCII characters to represent various parts of the game, although there had been many successful efforts to add more advanced graphics to make the game look more attractive. Despite the modest-looking graphics, the game is packed with many features including highly complex physics emulation (liquid and solid), path-finding of multiple characters based on various personal needs, and comprehensive mechanical construct emulation. Curiosity that is about the kill the Cat The game is closed source, so how it is designed and scaled is unknown to the public. That said, it seems to be a public understanding that the game, despite having many moving parts, is created to be a single-threaded program as was th...

The Hectoberfest

Hactoberfest A Hactoberfest takes place in October where coders are encourages to churn out a set amount of Pull Requests in the month. And a Pull Request is essentially a contribution made to the community. It is an interesting opportunity set to help motivate coders to take an active part in the open source communities in general. I certainly enjoyed the chance. This blog is dedicated to the Hactoberfest and acts as my index to my contributions and associated blogs. That Index I was talking about... A failed attempt that will be revisited and its blog Rocketfuel and Zinc and its blog Protein Powder Realism and its blog A lesson on .308 and its blog A tribute to Hannibal and its blog Awl-pike with a weight issue and its blog The Good I have made five pull requests, contributing to open source programs for the first time. In many ways, this is my dream come true; just 3 years ago, I never even thought this to be something within my power to do. I was always a cons...

Researching Awl Pike

Last time... In my previous commit, I had the pleasure of studying the guns and their ammo and how they are reflected in the world of Cataclysm-DDA. This time, the some members of the community were buzzing about a 3-meter-long pointy stick called awl pike. Awl Pike The awl pike is basically an extra-long spear designed specifically for use in a formation attack. A formation of 3+ ranks hold the longest possible stick at their disposal and poke the enemy that stands in front of them or charging at them. It is very powerful weapon against things that stands in front of them, but due to the need for formation and the shear unwieldiness of the weapon, it is not very versatile and adaptable to changing circumstances. In a one-on-one combat, the weapon would be very difficult to stay effective. How do I know all this? Well, there was the entire discussion about it in the issue page. Like I said, this kind of games brings out the geeks from their closets and provide the floor to sp...

All about the accuracy

The Gun Nuts Some of the most beautiful thing about open-source, rouge-like games are that it brings out the geeks in all of us. In one game , it brought out the geography geek to express themselves into the game that turns a simple management game into something that teaches you a bit about geographical compounds and where they are formed. In the case of Cataclysm-DDA, and in this particular issue, we tapped into the gun nuts. Based on some comprehensive review , someone provided a case to convince the community to fix a simple typo mistake. I mean, it's a typo mistake on a simple ammo object, and this person went and dug up information only the hard-core gun enthusiast would care to pen down! I certainly enjoyed reading and learning more about the world of guns, ammo, politics, military, and a piece of history just so that I can understand the need to add the negative sign in front of a number. It was fantastic. The fix This was a simple case. The issuer even spelt out e...

Meat grinder, Hannibal-style

The thing about Cataclysm-DDA is... This is a zombie-survival game. This part is going to be more gruesome than usual, so I suggest you spare yourselves and turn away right this moment. . . . . . . Proceed at your own discretion. . . . . . . You have been warned. . . . . . The survival is meant to be tough and difficult. A bunch of city-folks are thrown into the deep-end of the nature with added quirks of friendly next-door neighbors giving you a helping hand in becoming one with their stomach. No grocery stores, no farms, no livestock, no help, not at the beginning, anyways. Therefore, the game explored the possibility, and the horror, of survivors doing everything they must do to survive. That, to some, meant eating the flesh of other humans given the chance. The game features many meat-based food items, and almost all of them has a counterpart that uses human flesh in place. This includs the protein powder. I told you to look away. Caveat This particular...

Meet Grinder

Continuing on Cataclysm-DDA I have decided to work more with JSON of the game and resolve more conflicts and introduce more complexity to the game. This time, the issue was on creating protein powder. It is created from meat of some kind, and currently uses just fire to produce it. That doesn't seem right, now does it? Fire might be good for creating a steak, but how would the meat suddenly crumble into powder from that form? To resolve the issue, the issue creator called for adding mortal and pestle as additional necessity to create protein powder. Alright, so where are these powder git grep was my bread-and-butter of this particular activity. First, I wanted to know the object name of the protein powder. To that end, I searched for powder and landed on quite a number of results. Turns out, the name is simply protein_powder. Okay, so how about the mortar and pestle Again, git grep was very helpful. I also wanted to know how it was used as a part of the recipe, too. B...

Pwning my favorite game

Hectoberfest part 2: Pwning my favorite game While I have used various open source programs in daily bases, I have never imagined to be the one contributing to it. It has been the reason why I got interested in computer, so that was always my holy grail, but it was not until recently I could see myself as someone standing with the giants. Turns out, I can stand on their shoulders. What a view! Anyways, for my second PR, I decided to work on one of my favorite game: Cataclysm-DDA . It is about time my survivor got himself some rocket fuels! Cataclysm - Dark Days Ahead This is a rouge-like survival game. Your character is spawned in the middle of an unfriendly, zombie-infested world. Depending on the difficulty, you may spawn anywhere from a relatively safe bunker to neck-to-neck with the next-door, undead-and-hungry neighbors. The goal is to utilize every object and knowledge to gain an upper hand and survive. The player has the world at the disposal to craft and use. Speci...

Working with neovim.

The Overview I use vim every day. In the course of my use, I ran across neovim, a folk of vim with aim to introduce new features, such as asynchronous disk operation. I wanted to submit my first patch in hacktoberfest to this project. What is neovim This is a folk of vim. It has multiple aims, such as decreasing bloat, implement asynchronous disk operation, and to be a drop-in replacement of vim. It also aims to adopt different development culture than that of vim where the course of development is more open to the community. While all of them are interesting goals catering to specific needs, I am most interested in the asynchronous disk operation using libuv. What is libuv libuv is a set of libraries designed to perform asynchronous disk operations. It is widely used in projects such as node.js, and of course, neovim. What is the issue libuv has introduced uv_fs_copyfile() method. I intend on implementing this function in neovim. So far, I found two locations where neovim co...

Github, Issues, Pull Requests

My Issues with Github and Pulling my hair for it It all started when the venerable node.js implemented promise-based fs module. Shortly after, someone made Filer compatible with the promise-based operation. This is good. except now we need testers to ensure it works as expected. As an exercise in learning how to create issue and pull request on github, we were tasked to jump in and contribute. I chose to create a suit of tests for fs.promises.read() First strand of hair: the Beginning As this was my first time working in a serious project, I wasn't sure how things are organized in this repository, and I wasn't sure how to check if certain tests were implemented or not. I started my adventure in the node.js fs module that shows test coverage , and while it was an eye-opening information, it was unfortunately less relevant to the tasks at hand. So I went back and started opening up the test files in /tests/spec/ instead. I found many tests for the traditional call-back...

Node.js, fs, promises

Node.js and fs Node.js provides a general programming environment that utilizes JavaScript to perform logical operations. This allows a web development to be done entirely in JavaScript instead of needing extra languages to perform back-end processes and services. fs is a module in node.js that allows file system operation. This expands the functionality of JavaScript from mere browser language to something that can interact with the file system of the OS. Promises, Promises fs module traditionally used call-back function for its async operations. It has recently introduced Promise object alternatives for more robust programming. Promise object allows easy-to-read chaining of code to address the success or fail state of the given function, among many of its advantages. Practical example - link(2) We will be using link as an example. Link creates hard-links of the existing files. We will assume the following directory structure: ./ - file1 - file2 - file3 Using the cal...