Rust-GCC / gccrs

GCC Front-End for Rust
https://rust-gcc.github.io/
GNU General Public License v2.0
2.48k stars 159 forks source link

Mentions of go in rustspec.cc #389

Open CohenArthur opened 3 years ago

CohenArthur commented 3 years ago

go and libgo are mentionned quite a lot in rustspec.cc, during argument parsing. I'd like to help in removing the unneeded references by giving them a more rust-related name or removing them if necesary. Here are a few snippets:

  /* This is a tristate:
     -1 means we should not link in libgo
     0  means we should link in libgo if it is needed
     1  means libgo is needed and should be linked in.
     2  means libgo is needed and should be linked statically.  */
  int library = 0;

Is this needed? There is currently no librustto link against. That tristate is used quite extensively in the rest of the file.

  /* The first input file with an extension of .go.  */
  const char *first_go_file = NULL;

Replacing the various references with first_rust_file and changing its behavior to refer to an *.rs argument does not change the behavior of gccrs, and the tests still pass. But I'm assuming that it is unneeded and I guess it can be removed.

    case OPT_static_libgo:
      library = library >= 0 ? 2 : library;
      args[i] |= SKIPOPT;
      break;

Again, probably not in use right now.

Some of the references to go in this file have already been commented

philberty commented 3 years ago

I bootstrapped most of the front-end from the GCC GO code as you can see. I personally think we should try our best to strip this file down to be as basic as possible. We aren't taking advantage of anything there so it would be best when we do need to control linking flags etc that we are able to code review it properly.

Do any of @dkm or @tschwinge or @SimplyTheOther have any suggestions on how we go about cleaning this file up?

philberty commented 3 years ago

It is also relevant to point out that this is compiler driver and this will be important to figure out at a later date what compiler options we are missing down the line.