Project Stage 3
Goal:
After checking if the options are valid. Have to create a global array of afmv_targets and unsigned int of afmv_cnt. This is for others to consume.
-fafmv="default" will have a count of 0.
-fafmv="default, abc" will have a count of 1.
Try to use the target_clone in GCC.
Make a afmv.h for the global var I have to make.
Header file:
#ifndef GCC_AFMV_H
#define GCC_AFMV_H
/* Storage global variable for AFMV*/
#define AFMV_MAX_ARRAY_SIZE 100
extern unsigned int afmv_cnt;
extern char* afmv_targets[AFMV_MAX_ARRAY_SIZE];
#endif /* GCC_AFMV_H */
add include header in opts.cc
update count and array if all options passes the chceck.
unsigned int afmv_cnt = 0;
char* afmv_targets[AFMV_MAX_ARRAY_SIZE];
and
if (!is_found) {
error_at(loc, "Unsupported option '%s'", feature);
is_valid = false;
} else {
afmv_targets[afmv_cnt++] = feature;
}
at the end:
afmv_cnt--;
Becuase we want to set default as 0.
I am not sure if there will be any memory leak if i do it this way. I couldn't use the build in clone features to identify if the options are valid. I am using a hard coded arr for comparing.
Here is a link to my gcc Fork: https://github.com/Pulse6/gcc-command-line-parsing/tree/2024-S-command-line-parsing
Conclusion:
My task is to work with the current code base in GCC. It was hard to learn where things are at first because of it's huge code base, also we have a very limited time to learn and research to get to our goals. I have gain some knowledge of "make" and "make install" a version of GCC that I can modified. It is a similar concept to GIT, just for a version control. It is cool that makefile can re-build a version of your modified code and is able to know what I change and base on that it can only update and build the affected files. It is crazy to me that how much knowledge those who maintain the GCC code base. The little task I have to do for me is already overwhelming, but it is just a tiny part of GCC.
I have to find where do GCC takes in the command and where does it go. Also got to try follow the guideline of GCC. Used google to try to get some information of that. Went back to class recordings to get more out of it. Thankfully professor take the time to explain every task in details. Gives us a more clear path to go on.
This is also the first time I have work with a community GitHub project. First time doing forks of projects and making a pull request. That idea is also fun too. At the beginning of doing this task backs me back when i just started learning C is was so new and i have no idea what's going on, but if i keep on going to gets better. I did the same on this class/project. The sad part of this course is they made it in to a 7 week course. The course itself is already hard, and they make it half the time. However Chris our professor is a great teacher and make it much better to go through.
Comments
Post a Comment