Summary

Command line options for adding directories to include-path should prepend, not append

Metadata

Description

Options for `csc`, `chicken` and `csi` that add drectories to the current include path should prepend the added dirs instead of appending them, so the explicitly given include directories take precedence before previously existing ones.

This is consistent to how C compilers handle include paths.

Changes and comments

[2017-05-05 12:48:55 UTC] felix changed component from unknown to core tools

[2017-05-05 13:16:17 UTC] sjamaan changed description

[2017-10-26 21:10:56 UTC] felix wrote:

After checking the code for csi, chicken and csc, I think this behaviour seems to already the case.

Am I missing something?

[2017-10-26 21:17:48 UTC] sjamaan wrote:

Could this have been fixed by df49ac575c7e41c1ee5655b7d33b6575925db718?

[2017-10-26 21:18:15 UTC] sjamaan wrote:

(specifically with the introduction of ##sys#split-path)

[2017-10-26 21:34:51 UTC] sjamaan wrote:

Or could this have something to do with the fact that the CSC_OPTIONS and CSI_OPTIONS environment variables are appended at the end, even after the initial value of ##sys#include-pathnames (which is the result of (list (chicken-home)))?

[2017-10-26 23:30:18 UTC] felix wrote:

Replying to sjamaan: > Or could this have something to do with the fact that the CSC_OPTIONS and CSI_OPTIONS environment variables are appended at the end, even after the initial value of ##sys#include-pathnames (which is the result of (list (chicken-home)))?

But what would be the "right" behaviour? Currently the options from the env vars are prepended in csc.scm.

[2017-10-27 20:55:48 UTC] sjamaan wrote:

Replying to felix: > Replying to sjamaan: > > Or could this have something to do with the fact that the CSC_OPTIONS and CSI_OPTIONS environment variables are appended at the end, even after the initial value of ##sys#include-pathnames (which is the result of (list (chicken-home)))? > > But what would be the "right" behaviour? Currently the options from the env vars are prepended in csc.scm.

I'd expect explicitly supplied options on the command line to supersede options given in the environment, so I suppose prepending the options is correct. However, currently -I will be processed in order which means earlier options are searched first, so any -I in the CSC_OPTIONS will supersede any -I on the command line.

I don't know if there's a "correct" solution for this problem. Reversing the include-path seems weird too, because something like csc -I /foo -I /bar would then cause the compiler to search /bar before /foo, which is definitely not what one would expect.

All in all, I think the current situation is probably fine as it is. So maybe this should just be closed "works for me" and wait until someone comes up with a clearer example of what's wrong with the current situation?

[2017-10-27 21:26:36 UTC] felix changed status from new to closed

[2017-10-27 21:26:36 UTC] felix set resolution to worksforme

[2017-10-27 21:26:36 UTC] felix wrote:

Note that CSC_OPTIONS and CSI_OPTIONS are _prepended_ and thus superseded by explicit arguments, at least that is how I read the current implementation.

But I think you're right. There doesn't seem to be a correct way.