Opened 7 months ago

Closed 3 weeks ago

#1368 closed defect (worksforme)

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

Reported by: felix 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 7 months ago by felix

  • Component changed from unknown to core tools

comment:2 Changed 7 months ago by sjamaan

  • Description modified (diff)

comment:3 Changed 3 weeks ago by felix

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 3 weeks ago by sjamaan

Could this have been fixed by df49ac575c7e41c1ee5655b7d33b6575925db718?

comment:5 Changed 3 weeks ago by sjamaan

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

comment:6 follow-up: Changed 3 weeks 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 ; follow-up: Changed 3 weeks ago by 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.

comment:8 in reply to: ↑ 7 Changed 3 weeks 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 3 weeks ago by felix

  • Resolution set to worksforme
  • Status changed from new to closed

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.