Opened 8 years ago

Closed 7 years ago

#1368 closed defect (worksforme)

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

Reported by: felix winkelmann Owned by:
Priority: major Milestone: 5.0
Component: core tools Version: 4.12.0
Keywords: Cc: sjamaan
Estimated difficulty: easy

Description (last modified by sjamaan)

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.

Change History (9)

comment:1 Changed 8 years ago by felix winkelmann

Component: unknowncore tools

comment:2 Changed 8 years ago by sjamaan

Description: modified (diff)

comment:3 Changed 7 years ago by felix winkelmann

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

Am I missing something?

comment:4 Changed 7 years ago by sjamaan

Could this have been fixed by df49ac575c7e41c1ee5655b7d33b6575925db718?

comment:5 Changed 7 years ago by sjamaan

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

comment:6 Changed 7 years ago by 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)))?

comment:7 in reply to:  6 ; Changed 7 years ago by felix winkelmann

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.

comment:8 in reply to:  7 Changed 7 years ago by sjamaan

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?

comment:9 Changed 7 years ago by felix winkelmann

Resolution: worksforme
Status: newclosed

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.

Note: See TracTickets for help on using tickets.