halcompile: reject declarations that export the same HAL name - #4298
halcompile: reject declarations that export the same HAL name#4298tzuohann wants to merge 1 commit into
Conversation
ea6413a to
e1db816
Compare
|
Name collisions are bad by default and fail to compile. Why is there an option for this? You should be able to check this much easier using a parallel name array for target names (which you apparently do) without complex regexes or lambdas by using a simple Your second PR seems to be a duplicate and changes a generated (man) file that is not part of the repository. Why is this submitted twice? |
It's a 2.9 backport, no .adoc there, also threw me off... |
|
thanks. help me understand here. is this is a problem that can throw some people (amateurs using AI) off? if so and a little fix can help, I'll try to sharpen the solution. but if its not even an issue, i'll close the PR. |
e1db816 to
1188057
Compare
But they actually don't, I tested the claimed Edit: |
|
Still, the option is useless. |
ok I think this resolved the bit of confusion I as well as @grandixximo had. so this is a little problem that should be patched. but the option of hiding it is useless. i'll resubmit removing the option to hide it. thanks @BsAtHome |
A name declared in a .comp file is a C identifier, but it is exported
under a mangled HAL identifier: underscores become dashes and a trailing
dash or period is removed (comp.adoc, HALNAME). check_name_ok() compares
only declared names, so a component declaring both x_y and x_y_ exported
both as x-y. halcompile accepted it and the module failed at loadrt:
HAL: ERROR: duplicate variable 'collide.0.x-y'
collide: rtapi_app_main: Invalid argument (-22)
check_hal_name() rejects that at the offending line and points at the
HALNAME documentation. Functions are tracked separately from pins and
params, which share one namespace in hal_lib.c.
All 133 in-tree .comp files preprocess with no new error and no new
output. tests/halcompile/halname covers the rejection.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1188057 to
6b100fc
Compare
|
Wasn't this initially showing also info that the pins you will find in hal have different names? |
Per component: that's already what it did — one line per file with the names collapsed into it (my_input -> my-input, ...). But the build runs halcompile once per .comp, so its still 100+ lines on a full master build. One line for the whole build: It would have to be a fixed message from src/hal/components/Submakefile, which then can't name any actual pins. Also, in-tree only, so out-of-tree authors never see it. I have no clue how folks use this so I'll leave it to you guys to tell me what to do. |
You did do that originally, but that part has been removed, that is what I was saying, it is not there anymore, check the code... |
|
Isn't this already described in https://linuxcnc.org/docs/devel/html/en/hal/comp.html ? |
|
Correct, but the OP, before edits (the whole reason this PR started), was because the user and his AI missed that, the original proposal was a noisy An addition in the --help will improve visibility, and will weaken the "is not well documented" argument, after the addition in --help there are less excuses for missing it, AI or human... |
|
The --help is there to remind you of command line switches. Not to tell you how to write content. That belongs to the man pages and other documentation. The man-page is terse and should link properly to the docs. And, as you correctly said, no new is good news and errors/warnings are supposed to be one-liner messages with the correct information (in the correct format for IDEs to use). Relying on abnormal intelligence to do the right thing is like asking an amoeba to write Shakespeare. The letters are there but the meaning is lost. As they say, gigo. |
|
The man page argument has a hole for exactly the audience halcompile serves: component developers. They overwhelmingly work from a RIP build (git clone, make, rip-environment), and RIP installs nothing to MANPATH. For them
There is also in-tree precedent for non-switch guidance in this very usage() text: "Do not use [sudo] for RIP installation" is behavioral advice, not a switch reminder. Not proposing a tutorial, just 4 lines stating the one non-obvious semantic (C identifier => dashed HAL name) plus where to see the result ( |
pin in float my_inputis exported ascomponent.N.my-input— underscores become dashes (comp.adoc, HALNAME).A component that declares both
x_yandx_y_exports both asx-y. halcompile accepts it; the module then fails at loadrt:check_name_ok()only compares declared names.check_hal_name()rejects the collision at the offending line and points at the HALNAME documentation. Functions are tracked separately from pins and params, which share one namespace inhal_lib.c.Docs: NAMES section in the halcompile man page, note under the HALNAME table in comp.adoc. Tests:
tests/halcompile/halname. All 133 in-tree.compfiles preprocess with no new output.Backport for 2.9: #4299.
🤖 Generated with Claude Code