-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
include paths and include directive tidy up #102
Comments
Hi Felix. It is actually at the front still. Current search order for
This is what we want, I think. |
Tested by putting BROKEN
|
I see no issue with removing the implicit |
On Mon, Jan 03, 2022 at 07:39:15AM -0800, Neal wrote:
Current search order for `devel` as of 351f20e is
1. current working directory;
2. command line include directories;
3. ADMS include directory.
This is what we want, I think.
It should be changed to
1. command line include directories;
2. ADMS include directory.
because it makes more sense: you can add -I., but you can't un-add it.
Or: Find how do other tools implement `include, and decide based on
that.
Your -I patch + this fix + constants.vams is a good incentive to make a
release I reckon.
|
Removing it makes sense. I know that doing this alone will cause the Xyce It would be good to also implicitly look relative to the file being processed though, as that is fairly standard practice; e.g.,
should look relative to the file being proceed first (instead of the CWD) and then relative to any path declared by by the user with an explicit |
I would suggest we fix issue #39 too. The earliest version of |
I found a fix for issue #39 already. The last related thing I would suggest to get ADMS usable with the most recent Accellera standard library files is to get around their (presumably deliberate) use of an escaped identifier inside the
It's not great but it's much better than not doing anything at all. We'd just need to document the heck out of this! What do you think? |
Just weighing in here: I do not really like the suggestion of removing "search current directory" as a default behavior for ADMS, mostly because of the impact it will have on Xyce's use of ADMS. Verilog-A models are often shipped as bundles of files that include each other in the same directory, and requiring an explicit "search this directory" command line option would be annoying given that it has always been the default behavior for as long as ADMS has existed. Could we please just leave it as it is? |
On Mon, Jan 03, 2022 at 11:43:50AM -0800, Tom Russo wrote:
Verilog-A models are often shipped as bundles of files that include
each other in the same directory, and requiring an explicit "search
this directory" command line option would be annoying given that it
has always been the default behavior for as long as ADMS has existed.
I see your point. Note that "include each other in the same directory"
was never the behaviour (unless that directory happens to be '.').
Could we please just leave it as it is?
If someone sends a patch to make "include each other in the same
directory" work, I will certainly consider it. Better pass '-I.' where
needed.
|
I will note that other Verilog-A compilers (Agilent's, for example) search for include files without a specified path by looking first in the same directory as the file being processed, then in any other search path given to the compiler. If ADMS were changed to do that, I'd be behind it (though I'm not going to submit a PR to make it happen). But until that happens, please do not remove the default of looking in the current working directory first. Especially since this is long-standing behavior since the dawn of ADMS. |
On Mon, Jan 03, 2022 at 12:21:00PM -0800, Tom Russo wrote:
I will note that other Verilog-A compilers (Agilent's, for example)
search for include files without a specified path by looking first in
the same directory as the file being processed, then in any other
search path given to the compiler.
Thanks. That confirms my suspicion.
If ADMS were changed to do that, I'd be behind it (though I'm not
going to submit a PR to make it happen). But until that happens,
please do not remove the default of looking in the current working
directory first. Especially since this is long-standing behavior
since the dawn of ADMS.
Agreed, lets do all or nothing.
|
This appears to be all that is needed for this.
This would make ADMS behave similarly to other Verilog-A compilers. I am fairly sure that this wouldn't interfere with how Xyce uses ADMS. The CWD could always be manually added with the |
On Mon, Jan 17, 2022 at 04:36:04AM -0800, Neal wrote:
- adms_slist_push(&pproot()->includePath,(p_adms)".");
+ adms_slist_push(&pproot()->includePath,(p_adms)dirname(myverilogamsfile));
This would make ADMS behave similarly to other Verilog-A compilers. I
am fairly sure that this wouldn't interfere with how Xyce uses ADMS.
The CWD could always be manually added with the `-I.` command line
option.
Thanks for looking into this one.
I have doubts about the correctness of the approach, and I am unsure
what "correct" even means. How about
A.va # `include "sub/B.va"
sub/B.va # `include "C.va"
sub/C.va # the desired file
C.va # a stray (but wrong) file.
Will it not include the wrong one? (What will others do here?)
What happens if -I. is passed in the above example? will C.va or
sub/C.va win? Is there anything in the standard on this at all?
(Same question with -Isub, and no "sub/" in A.va.)
I like the idea of a tradeoff between unconditional -I. and a correct
implementation, and I think your patch has a chance. What if users start
depending on odd behaviour (again)?
|
Ahh yes. This will not work with nested include files. It will only add the directory of the base Verilog-A file to the include path. I will give this some more thought. |
The Verilog-AMS standard refers to the Verilog standard, which does not explicitly specify how relative paths should be evaluated. From what I can see, any change would need to occur in the |
I think this does what you're after.
I think the implicit Here is an example of it working.
If you uncomment the include for
|
I'm not 100% sure on whether this will work on Windows yet. Also, the |
On Sun, Jan 23, 2022 at 09:46:29AM -0800, Neal wrote:
Also, the `dirname` function had already been defined statically in `admsXml.c` meaning it's not defined in library `admsElement` like almost all other functions of this kind are. `admsXml.c` is used to create `admsXml`; but if you ever wanted to link against the `admsPreprocessor` library elsewhere you'd run into problems. Is it worth relocating the `dirname` and dependent functions? They could be made part of `mkelements.pl`. I'm thinking it would be safer and more consistent. Could we rename `dirname` to `adms_dirname` at the same time perhaps, as `dirname` is a standard library (`string.h`) function name?
Sounds reasonable to me.
As I understand, the static implementation of dirname should be moved to
the library and exported as adms_dirname together with the others.
|
I was mostly suggesting this for consistency. I did test that it works. I'm now thinking it's better if we don't, given what I know now. On Windows, the We only use |
I think #109 as it stands (https://github.com/Qucs/ADMS/pull/109/files) is the best solution. |
On Mon, Jan 24, 2022 at 06:27:47AM -0800, Neal wrote:
I suspect why I can get away with leaving it defined as `static` is
because `admsXml` is built from a single file and
`libadmsPreprocessor` is only ever used for building this one file.
On my system, libadmsPreprocessor is a shared library, and does not prescribe
the use together with admsXml.c. I don't understand how it can use a static
function from another binary. Does it not call the one from dirname(3)?
$ ldd `which admsXml`
linux-vdso.so.1 (0x00007ffd495af000)
libadmsElement.so.0 => /usr/lib/x86_64-linux-gnu/libadmsElement.so.0 (0x00007ff450f45000)
libadmsVeriloga.so.0 => /usr/lib/x86_64-linux-gnu/libadmsVeriloga.so.0 (0x00007ff450f2e000)
libadmsPreprocessor.so.0 => /usr/lib/x86_64-linux-gnu/libadmsPreprocessor.so.0 (0x00007ff450f1c000)
libadmsAdmstpath.so.0 => /usr/lib/x86_64-linux-gnu/libadmsAdmstpath.so.0 (0x00007ff450ed2000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff450cd3000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff450f99000)
admsXml.c looks messy. Perhaps I need to build with your patch and look
closer.
|
Ahh! You are correct that |
On Mon, Jan 24, 2022 at 08:55:46AM -0800, Neal wrote:
Ahh! You are correct that `libadmsPreprocessor`, in my patch, it not
using the `dirname` from `admsXml.c` at all; it must somehow be
finding dirname(3). We could declare the ADMS `dirname` in a common
location and rename it `adms_dirname` as I previously suggested;
putting it in `libElements` sounds sensible as it is already used when
building both `libadmsPreprocessor` and `admsXml`. There are quite a
few static function in `admsXml.c`. We would only really need to move
those related to file path manipulation. I will update my pull
request.
We are getting there.
If adms_dirname implements the same as dirname from POSIX.1-2001, I
don't think it is sensible to add it to any of the adms libraries.
The static functions in admsXml.c are misplaced at best, and should be
(re)moved. If they were added in an attempt to use a non-POSIX platform,
they need to be enabled only as needed (e.g. on a specific platform),
and wrap to corresponding library calls if applicable.
Maybe just #include <libgen.h> (to get the dirname declaration) and call
it a day.
|
I think the One thing to bare in mind is that paths in Verilog-A source code will use the forward slash as the path separator. Cygwin/MinGW versions of There is one notable difference. The |
On Mon, Jan 24, 2022 at 01:33:32PM -0800, Neal wrote:
I wouldn't want to make any more changes myself at this stage [..]
I'd be happier if we didn't add more functions to the interface,
especially not when they are questionable or bogus or unneeded.
How about pasting an inline/static definition of (adms_?)dirname where
you need it, and leave the tidy-up to future devs?
Cleaning up the code will have fewer side effects than reverting the
interface changes...
|
I see your point. I originally thought the interface change would be less bad than repeating code. If the intention is to refactor later on then I agree that it'd be better to add a static function that can be sorted out later; this way all of the changes needed to get this working are localised to just one file. I have updated my pull request. |
Currently admsXml adds '.' (current working directory) to the back of the include path list. This seems wrong and unusual. The C preprocessor has a more well behaved include directive, and does not do this.
NB: C has two different includes (quotes vs angle brackets) and the comparison might be inappropriate. It would be better to compare with some other verilog tool.
NB2: The reason the extra '.' has been added is probably related to the generation of header files (in '.'). This only caused problems (due to race conditions) and is no longer needed.
As a start, the implicit '.' should be removed, and instead specified by the user ('-I.') on demand. Then, less importantly, include directives should be resolved relative to the file they occur in, such that files in the same directory are found (unless found in a path specified by -I).
The text was updated successfully, but these errors were encountered: