On Wed, Apr 21, 2021 at 11:16 AM Liu Hao <lh_mouse@xxxxxxx> wrote: > > 在 2021-04-21 16:59, Xi Ruoyao via Gcc-help 写道: > > > > GCC is never designed to be a tool for teaching or learning. It's a > > compiler, for compiling programs in real-life. Basically -v is only > > intended to debug GCC itself. > > > > May be GCC isn't, but it *happens to*, and I think it is a good one, because it's free software and > comes with a huge community. > > > > Unfortunately, while every physics teacher knows he/she shouldn't use a > > car to teach mechanics, many CS101 teachers keep telling the student "if > > you don't understand something, just do a experiment". IMO it's pure > > laziness. > > > > The purpose of the topic of this thread is a bit dubious. As you have pointed out, as a driver (not > a compiler or front-end whatsoever!), how GCC invokes other programs (cc1, cc1plus, collect2, as, > ld, and so on) is purely implementation details, which users shouldn't care about. But save for > that, I fail to see anything wrong with the question itself, and I disagree with you: It is almost > always better for students to learn from their experiences, their mistakes, their failures, rather > than textbooks. Exactly. Learning from a textbook is a typical mindset that a student tends to have. That doesn't work well for any field strongly tied with practice. > Nonetheless, there are still metaphysical things that people can't learn from > experiences (e.g. undefined behavior). > > > > You can read libtool code, for example. Libtool is basically a > > compatibility wrapper for gcc/ld/ar. I'm sure everyone will feel > > disgusting by reading 12562 lines of shell code in it. > > > > Modern libtool uses `$(CXXLD)` for linking, which is usually the same as `$(CXX)`. > > Shell is less favorable because 0) it may not be available on some hosts (note: mingw), Is this for windows? Do people use gcc for Windows? > and 1) it is > too error-prone especially on arguments that contain spaces, and 2) it is > undesirable to have to > place more incompatibility and limitation (e.g. number of bytes in a single command line) just > because of the shell being used, but not of GCC itself, and 3) it is indeed very slow if `fork()` is That is the misconcept I mentioned before. To improve the speeds shell scripts should be sourced (then call functions defined in it, which can be used many times without much overhead) instead of used as a standalone program. The speedup can be 10~100 x depending on the situation. > either slow or unavailable completely. > > > [And please don't deviate from the topic.] > > > -- > Best regards, > Liu Hao > -- Regards, Peng