-
Notifications
You must be signed in to change notification settings - Fork 3k
Readable error when toolchain paths not set. Allow IAR and ARM toolchains to be set in user's PATH. #2418
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
Conversation
Fixes ARMmbed#2360. New error: [Error] Toolchain path does not exist for IAR. Current value: /default/path/that/doesnt/exist (System exit before any build system calls)
Can we exit with non-zero? It's an error after all. |
After exiting non-zero, LGTM. |
48dfba8
to
51245ce
Compare
if not exists(self.toolchain_path): | ||
print('[ERROR] Toolchain path for %s does not exist.\n' | ||
'Current value: %s' % (self.name, self.toolchain_path)) | ||
sys.exit(-1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have any documentation about exit codes like this? would be useful in some cases if all possible exit codes are well known&documented..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jupe I don't think anyone has looked at standardizing the return codes across the tools yet, that needs to be revisited in another PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, we return 2 on all argument errors after #2393 gets merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well that's a step in the right direction! I guess my point was we haven't specified a full list of return codes for the tools yet. I think it make sense to look at that collectively across all scripts and make that change in one PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, and we should add it to the documentation somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we open an issue, so we don't forget?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats good starting point 👍 . Somebody should look about existing return codes, standardize all of them and prepare proper documentation..
Copying this over from #2416 (@sarahmarshy can this PR just be updated from now on instead of moving it?)
|
I agree, the toolchains should just throw an exception. This helps out with online build system compatibly.
I can set the |
Not sure exactly what you mean @theotherjimmy ? |
Setting the path to |
Does it do this for all toolchains now? Including IAR? It was my impression that this only worked for GCC_ARM |
@bridadan yes, we can just update this. I think it is at the point where I can make commits instead of new branches to implement the changes listed. Let me look into checking |
Instead of branches and duplicate PR's, you could force push to overwrite the old branch. |
But that would cause a lot of the conversation to look out of context for posterity, |
I think it would show all of the related conversation in the same thread, which might be preferred. This is off topic, if you want to continue this discussion we should do it 'offline'. |
Back to on topic: looks like https://docs.python.org/dev/library/shutil.html#shutil.which would be a good solution for executables in the path that aren't assigned an environment variable. It is only supported in python 3.3, but I will try to find a 2.7 alternative. |
@sarahmarshy I did an implementation of this here: https://github.com/ARMmbed/mbed-os/pull/2057/files#diff-1832807e55f923dee42eee74919441faR69 The PR itself wasn't ready to merge but there might be some code there you can salvage! |
@bridadan going to try this https://docs.python.org/release/2.4/dist/module-distutils.spawn.html first! |
I remember looking at that function and kind of straying away from it due to some of the comments in this Stack Overflow post: http://stackoverflow.com/questions/377017/test-if-executable-exists-in-python But I never actually tried it, so it may be just fine! |
It is working alright in gcc, it is also working for arm, but there are issues with arm because we manually append the bin path like:
so, if you leave the path blank the command becomes: I could modify this to have different behavior when the path is blank.
Are you sure you do that? Can you check? I am not able to do this successfully. |
I can check tomorrow. Right now I don't have armc5 installed. But, I don't consider it blocking. |
print('[ERROR] Could not find executable for %s.\n' | ||
'Currently set search path: %s' | ||
% (self.name, self.toolchain_path)) | ||
sys.exit(-1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we come to a decision about calling exit within toolchains? I'd still vote no on this and throw an exception instead
0e04df0
to
f661e55
Compare
""" | ||
def perform_check(self, *args, **kwargs): | ||
if not exists(self.toolchain_path): | ||
print('[ERROR] Could not find executable for %s.\n' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you move this message into the exception you raise below, it will be passed to anything that catches it, which can then print it or ignore.
raise Exception("[ERROR] Could not find executable...")
+1 on the idea (haven't reviewed the whole implementation yet) |
@sg- I'm not sure why ARM and IAR have to know the paths to the bin and the include stuff separately? Aren't they aware of these paths themselves? Or is this needed for ulib support for ARM? |
@sg- This implementation uses a decorator for the compile, build, and link functions. It will check whatever would be used as the path to the command. Assuming that config makes its way to I can try to look into why we need those includes separately. |
2871570
to
205160b
Compare
Raise exceptin instead of exit. Corrected error for arm-none-eabi-gcc/g++ set in path.
205160b
to
cd229ba
Compare
@@ -56,6 +56,11 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False, | |||
else: | |||
cpu = target.core | |||
|
|||
if not TOOLCHAIN_PATHS['ARM']: | |||
exe = find_executable('armcc') | |||
if exe: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if this condition fails. line 64 assumes ARM path in dict TOOLCHAIN_PATHS. Perhaps raise an exception. Though not sure if this class is instantiated on selection of -t ARM
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not raise an exception here because I did not want the constructor to fail. The exception will be raised before compile_sources, link_program, or build_library. Nothing in this scope actually executes the command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My question was actually local. If if exe
fails then at line 64 TOOLCHAIN_PATHS['ARM']
will give KeyError
exception.
If you don't care about actual path being constructed then you can do TOOLCHAIN_PATHS.get('ARM', '')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why the constructor shouldn't fail? It looks like bailing out as soon as the error is found would be a good thing. Sorry if I'm missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please ignore my comment. I can see that TOOLCHAIN_PATHS['ARM'] is already initialized tools.toolchains.__init__.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has this been checked for all the o/s's we may come across?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bogdanm @theotherjimmy has strong opinions here. I agree that we are delaying failure. But I think it is generally assumed that when you are constructing an object, it will succeed. Though I think __init__
is not a constructor in the same way as C++.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
init is definitely not a constructor in the same sense as a C++ constructor. Exceptions inside constructors in C++ are bad because they might leave the object in an inconsistent state. That's hardly a concern here, when the outcome is that your program terminates with an error message. But in any case, this isn't a huge deal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, my beef with the constructor failing has nothing to do with any of that. It's pretty simple: A constructed toolchain is required for an exporter. The online tools have only armc5. We need to be able to export to non-armc5 IDE's. So we must not fail to construct a toolchain when it's executable is not present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I misunderstood. That makes a lot of sense.
PR looks good overall (with the above comments). I'd also add another change that sets all the paths in |
@bogdanm I think that is a good solution. Then, if mbed_settings variables are not set, the value on the PATH will be used. |
I agree with Bogdan about empty strings. It forces the user to think about whether they have configured paths or not. With the non-empty defaults you can get some weird error messages that are not always quick to work out |
@adbridge Yes, the [OS ERROR] was the original motivation for this PR. |
Tested on Mac.
I dont have armcc installed so that is why its not found |
…..91acece 91acece Remove test files 6568bc1 Merge branch 'release_internal' into release_external 4192cc8 Added configuration for RADIUS retry timer (ARMmbed#2438) 684b714 Added support for retries and multiple sockets to RADIUS client (ARMmbed#2426) 89e0ae0 WS: Restart auto CCA threshold after discovery (ARMmbed#2435) dbb09b1 MAC/WS: Min possible Tack to 1ms and CCA interval to 2ms (ARMmbed#2434) 43b2ae2 Cca threshold test (ARMmbed#2436) 28108e1 Added device min sensitivity setting and stack information 7060c70 Cca threshold test (ARMmbed#2432) 640be71 WS: temporarily set default CCA threshold to -80 (ARMmbed#2431) 0a472ae WS: Calculate UFSI drift and trace (ARMmbed#2430) 61d3db8 Create APIs for DNS cache results 587add5 MAC: Validate TX time (ARMmbed#2429) a1bfed4 Added typecast when computing max_timout from drift (ARMmbed#2428) 089fb3b Neighbour temporary entry update and Enhanced ACK tx update 70244f6 Wi-sun parameter and debug trace update 5752eae Created validate TX time handler (ARMmbed#2423) 022d61f Wi-sun Neighbour table update and DHCP new callback 857b41f Merge pull request ARMmbed#2421 from ARMmbed/update_from_mbed_os 1a9dd13 (via Mbed-OS)WS Management API missing include 4318f37 Calculate drift in critical state (ARMmbed#2419) 01a1909 FHSS WS: Do not use drift compensation with unpredictable linux timer (ARMmbed#2418) git-subtree-dir: features/nanostack/sal-stack-nanostack git-subtree-split: 91acece
…..d879e6d d879e6d Merge branch 'release_internal' into release_external eef9246 Fixed network border router timeout recovery and EAPOL relay address fix bac7ca6 Changed RADIUS MTU and small fixes a9f8b75 Addeed support for DHCP vendor data d8f0003 DHCPv6 functionality update 7fe0423 Added DHCPv6 vendor data generation for DNS queries 639f9db FHSS: Changed retry backoffs when no BC schedule or TX slots (ARMmbed#2440) 91acece Remove test files 6568bc1 Merge branch 'release_internal' into release_external 4192cc8 Added configuration for RADIUS retry timer (ARMmbed#2438) 684b714 Added support for retries and multiple sockets to RADIUS client (ARMmbed#2426) 89e0ae0 WS: Restart auto CCA threshold after discovery (ARMmbed#2435) dbb09b1 MAC/WS: Min possible Tack to 1ms and CCA interval to 2ms (ARMmbed#2434) 43b2ae2 Cca threshold test (ARMmbed#2436) 28108e1 Added device min sensitivity setting and stack information 7060c70 Cca threshold test (ARMmbed#2432) 640be71 WS: temporarily set default CCA threshold to -80 (ARMmbed#2431) 0a472ae WS: Calculate UFSI drift and trace (ARMmbed#2430) 61d3db8 Create APIs for DNS cache results 587add5 MAC: Validate TX time (ARMmbed#2429) a1bfed4 Added typecast when computing max_timout from drift (ARMmbed#2428) 089fb3b Neighbour temporary entry update and Enhanced ACK tx update 70244f6 Wi-sun parameter and debug trace update 5752eae Created validate TX time handler (ARMmbed#2423) 022d61f Wi-sun Neighbour table update and DHCP new callback 857b41f Merge pull request ARMmbed#2421 from ARMmbed/update_from_mbed_os 1a9dd13 (via Mbed-OS)WS Management API missing include 4318f37 Calculate drift in critical state (ARMmbed#2419) 01a1909 FHSS WS: Do not use drift compensation with unpredictable linux timer (ARMmbed#2418) git-subtree-dir: features/nanostack/sal-stack-nanostack git-subtree-split: d879e6d
…8609ae..d879e6d d879e6d Merge branch 'release_internal' into release_external eef9246 Fixed network border router timeout recovery and EAPOL relay address fix bac7ca6 Changed RADIUS MTU and small fixes a9f8b75 Addeed support for DHCP vendor data d8f0003 DHCPv6 functionality update 7fe0423 Added DHCPv6 vendor data generation for DNS queries 639f9db FHSS: Changed retry backoffs when no BC schedule or TX slots (ARMmbed#2440) 91acece Remove test files 6568bc1 Merge branch 'release_internal' into release_external 4192cc8 Added configuration for RADIUS retry timer (ARMmbed#2438) 684b714 Added support for retries and multiple sockets to RADIUS client (ARMmbed#2426) 89e0ae0 WS: Restart auto CCA threshold after discovery (ARMmbed#2435) dbb09b1 MAC/WS: Min possible Tack to 1ms and CCA interval to 2ms (ARMmbed#2434) 43b2ae2 Cca threshold test (ARMmbed#2436) 28108e1 Added device min sensitivity setting and stack information 7060c70 Cca threshold test (ARMmbed#2432) 640be71 WS: temporarily set default CCA threshold to -80 (ARMmbed#2431) 0a472ae WS: Calculate UFSI drift and trace (ARMmbed#2430) 61d3db8 Create APIs for DNS cache results 587add5 MAC: Validate TX time (ARMmbed#2429) a1bfed4 Added typecast when computing max_timout from drift (ARMmbed#2428) 089fb3b Neighbour temporary entry update and Enhanced ACK tx update 70244f6 Wi-sun parameter and debug trace update 5752eae Created validate TX time handler (ARMmbed#2423) 022d61f Wi-sun Neighbour table update and DHCP new callback 857b41f Merge pull request ARMmbed#2421 from ARMmbed/update_from_mbed_os 1a9dd13 (via Mbed-OS)WS Management API missing include 4318f37 Calculate drift in critical state (ARMmbed#2419) 01a1909 FHSS WS: Do not use drift compensation with unpredictable linux timer (ARMmbed#2418) git-subtree-dir: connectivity/nanostack/sal-stack-nanostack git-subtree-split: d879e6d
…8609ae..d879e6d d879e6d Merge branch 'release_internal' into release_external eef9246 Fixed network border router timeout recovery and EAPOL relay address fix bac7ca6 Changed RADIUS MTU and small fixes a9f8b75 Addeed support for DHCP vendor data d8f0003 DHCPv6 functionality update 7fe0423 Added DHCPv6 vendor data generation for DNS queries 639f9db FHSS: Changed retry backoffs when no BC schedule or TX slots (ARMmbed#2440) 91acece Remove test files 6568bc1 Merge branch 'release_internal' into release_external 4192cc8 Added configuration for RADIUS retry timer (ARMmbed#2438) 684b714 Added support for retries and multiple sockets to RADIUS client (ARMmbed#2426) 89e0ae0 WS: Restart auto CCA threshold after discovery (ARMmbed#2435) dbb09b1 MAC/WS: Min possible Tack to 1ms and CCA interval to 2ms (ARMmbed#2434) 43b2ae2 Cca threshold test (ARMmbed#2436) 28108e1 Added device min sensitivity setting and stack information 7060c70 Cca threshold test (ARMmbed#2432) 640be71 WS: temporarily set default CCA threshold to -80 (ARMmbed#2431) 0a472ae WS: Calculate UFSI drift and trace (ARMmbed#2430) 61d3db8 Create APIs for DNS cache results 587add5 MAC: Validate TX time (ARMmbed#2429) a1bfed4 Added typecast when computing max_timout from drift (ARMmbed#2428) 089fb3b Neighbour temporary entry update and Enhanced ACK tx update 70244f6 Wi-sun parameter and debug trace update 5752eae Created validate TX time handler (ARMmbed#2423) 022d61f Wi-sun Neighbour table update and DHCP new callback 857b41f Merge pull request ARMmbed#2421 from ARMmbed/update_from_mbed_os 1a9dd13 (via Mbed-OS)WS Management API missing include 4318f37 Calculate drift in critical state (ARMmbed#2419) 01a1909 FHSS WS: Do not use drift compensation with unpredictable linux timer (ARMmbed#2418) git-subtree-dir: connectivity/nanostack/sal-stack-nanostack git-subtree-split: d879e6d
Fixes #2360.
New error:
[ERROR] Could not find executable for IAR.
Currently set search path: /default/path/that/doesnt/exist
(System exit before any build system calls)
@theotherjimmy @0xc0170 @bridadan