Repository navigation
Commit 69df389
committed
fix(core): reject use_libdevice on the NVRTC and PTX backends
`ProgramOptions.use_libdevice` is documented "Only supported for the NVVM
backend", but the guard enforcing that was written in `Program_init`'s final
`else` -- the branch reached only when `code_type` is not a backend at all:
else:
supported_code_types = tuple(x.value for x in SourceCodeType)
if options.use_libdevice:
raise ValueError("use_libdevice is only supported by the NVVM backend")
raise RuntimeError(f"Unsupported {code_type=} ({supported_code_types=})")
So it never fires for the two real non-NVVM backends, and it fires for the
wrong reason on a typo:
* `Program(src, "c++", ProgramOptions(use_libdevice=True))` and the "ptx"
equivalent are accepted silently. `self._use_libdevice` is initialised to
False and only set inside the `nvvm` branch, so libdevice is never loaded
and the caller learns about it from undefined-symbol errors at link time
instead of from the documented up-front ValueError.
* `Program(src, "bogus", ProgramOptions(use_libdevice=True))` raises
"use_libdevice is only supported by the NVVM backend", which says nothing
about the code_type that is the actual problem.
Move the check next to the per-branch `extra_sources` guards, which are the
sibling option with the same "NVVM only" contract and are already duplicated
into the "c++" and "ptx" branches, and drop it from the `else` so an
unrecognised code_type reports itself.1 parent 3bd069a commit 69df389
3 files changed
Lines changed: 55 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
771 | 771 | | |
772 | 772 | | |
773 | 773 | | |
| 774 | + | |
| 775 | + | |
774 | 776 | | |
775 | 777 | | |
776 | 778 | | |
| |||
789 | 791 | | |
790 | 792 | | |
791 | 793 | | |
| 794 | + | |
| 795 | + | |
792 | 796 | | |
793 | 797 | | |
794 | 798 | | |
| |||
835 | 839 | | |
836 | 840 | | |
837 | 841 | | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
838 | 847 | | |
839 | | - | |
840 | | - | |
841 | 848 | | |
842 | 849 | | |
843 | 850 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
76 | 84 | | |
77 | 85 | | |
78 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
348 | 362 | | |
349 | 363 | | |
350 | 364 | | |
| |||
718 | 732 | | |
719 | 733 | | |
720 | 734 | | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
721 | 751 | | |
722 | 752 | | |
723 | 753 | | |
| |||
831 | 861 | | |
832 | 862 | | |
833 | 863 | | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
834 | 872 | | |
835 | 873 | | |
836 | 874 | | |
| |||
0 commit comments