Skip to content
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

Remove '#line 1' from flex generated files to avoid bug in nvcc with CMake + Ninja + CUDA builds of Trilinos #97

Closed
bartlettroscoe opened this issue Mar 9, 2018 · 2 comments

Comments

@bartlettroscoe
Copy link
Contributor

There is a strange defect with nvcc when calling through Ninja as generated by CMake described in trilinos/Trilinos#2359 that causes nvcc to spit out incorrect dependencies for all line in source files of the form #line 1 <some-file>. This results in unnecessary rebuilds of a bunch of files when ever ninja is called to build. A defect report has been filed with NVIDA but the workaround is to just remove the lines #line 1 <some-file> from all of the flex generated SEACAS source files. In particular, with the patch:

diff --git a/packages/seacas/libraries/aprepro_lib/apr_scanner.cc b/packages/seacas/libraries/aprepro_lib/apr_scanner.cc
index 747470a..a2512cd 100644
--- a/packages/seacas/libraries/aprepro_lib/apr_scanner.cc
+++ b/packages/seacas/libraries/aprepro_lib/apr_scanner.cc
@@ -971,7 +971,6 @@ static yyconst flex_int16_t yy_rule_linenum[102] = {
 #define yymore() yymore_used_but_not_detected
 #define YY_MORE_ADJ 0
 #define YY_RESTORE_YY_MORE_OFFSET
-#line 1 "/scratch/gdsjaar/seacas/packages/seacas/libraries/aprepro_lib/aprepro.ll"
 /* -*- Mode: c++ -*- */
 #line 39 "/scratch/gdsjaar/seacas/packages/seacas/libraries/aprepro_lib/aprepro.ll"

or the patch

diff --git a/packages/seacas/libraries/aprepro_lib/apr_scanner.cc b/packages/seacas/libraries/aprepro_lib/apr_scanner.cc
index 747470a..5774992 100644
--- a/packages/seacas/libraries/aprepro_lib/apr_scanner.cc
+++ b/packages/seacas/libraries/aprepro_lib/apr_scanner.cc
@@ -971,7 +971,7 @@ static yyconst flex_int16_t yy_rule_linenum[102] = {
 #define yymore() yymore_used_but_not_detected
 #define YY_MORE_ADJ 0
 #define YY_RESTORE_YY_MORE_OFFSET
-#line 1 "/scratch/gdsjaar/seacas/packages/seacas/libraries/aprepro_lib/aprepro.ll"
+#line 2 "/scratch/gdsjaar/seacas/packages/seacas/libraries/aprepro_lib/aprepro.ll"
 /* -*- Mode: c++ -*- */
 #line 39 "/scratch/gdsjaar/seacas/packages/seacas/libraries/aprepro_lib/aprepro.ll"

both solve the problem.

I can change this in the snapshot of this file in Trilinos but it would just get overwritten the next time that SEACAS was snapshotted into Trilinos.

Is there any way to avoid this #line 1 from getting into these generated files?

bartlettroscoe added a commit to bartlettroscoe/seacas that referenced this issue Mar 10, 2018
This remove the line starting wtih '#line 1' which causes nvcc to create a
wrong dependency on apr_scanner.o based on the non-existant file
/scratch/gdsjaar/seacas/packages/seacas/libraries/aprepro_lib/aprepro.ll.  See
trilinos/Trilinos#2359.

This is the same patch as the Trilinos patch in PR trilinos/Trilinos#2360.  By
making this patch here as well, the next time SEACAS is snapshotted into
Trilinos, it will not overwrite the patch in trilinos/Trilinos#2360 being
committed to Trilinos.

But the right solution will be to avoid lines starting with '#line 1' in the
future when generating these files.
@bartlettroscoe
Copy link
Contributor Author

@gsjaardema ,

I created the PR #98 for a short-term fix for this. But the long term fix (other than getting an updated CUDA with a fixed nvcc) is to avoid having these generated files have #line 1 <some-file>.

What is the best long-term solution for avoiding #line 1 lines?

@gsjaardema
Copy link
Member

Fixed in 0020417.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants