Isn't there a possibility to cache the results of the system checks inside incdir.sh?

The cost of getting 'os' is fork + new shell + uname
The cost of gcc is fork + new shell + grep
The cost of exfile if for + new shell + basename

Yes, so that does have to fork a lot of additional shell instances.  Perhaps you could use environment variables to cache results.  I think that Bash can access environment variables without forking.

For example,  I think that you replace the line:

    os=`uname -o 2>/dev/null || echo "Other"`

with

    |if[-z ${os+x}];then|
    export os=`uname -o 2>/dev/null || echo "Other"`
    fi

See discussion of syntax at https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash

We could probably greatly improve build performance if this were done throughout the OS.  An alternative might be to set a large set of environment variables as part of the 'make context' phase.

In either case, we would also have to unset the environment variables on distclean as well.

Another, probably better solution, would be to re-write incdir.sh in C.  Then it would not require a fork to bet to uname() or basename().  Host C is supported on all platforms and would not require additional build tools (as would, say, Python or other scripting language).  C is also portable and can work in all POSIX environments and Windows native environments.

There are C versions of several .sh files under tools now, so it is not a radical idea.

And actually it would not be too difficult to do.  I could even do that if you agree to that solution.


Reply via email to