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

Fix CFLAGS & Makefile issues #2168

Merged
merged 2 commits into from
Jan 3, 2019
Merged

Fix CFLAGS & Makefile issues #2168

merged 2 commits into from
Jan 3, 2019

Conversation

fx-carton
Copy link
Contributor

@fx-carton fx-carton commented Dec 29, 2018

This PR fixes #2049
The arguments are split by ' ' instead of '-', so the bugs where other filenames are appended to the flags are fixed. The cases with quoted arguments containing spaces are handled, as well as arguments separated with spaces (eg. -D directory).

Copy link
Member

@w0rp w0rp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tests. Add test cases to the file that exists for testing this to test for the problem case you identified.

@w0rp w0rp added the fix tests label Dec 29, 2018
Split by space instead of dash.
This prevents incorrect parsing where space-separated arguments are
merged (in particular, .c or .o files were appended to -I or -D
arguments).

Handle shell escape: quotes and escaped quotes \" and shell
substitutions are recognised. This is done by verifying that no special
character (" ' ` ()) has not a matching character.

Fixes #2049
@fx-carton
Copy link
Contributor Author

I added a test that fails with current master and is fixed with this PR.

@w0rp
Copy link
Member

w0rp commented Jan 3, 2019

Sure, as long as there are tests to cover all of the interesting cases, I'm happy.

@w0rp w0rp merged commit 1b264b8 into dense-analysis:master Jan 3, 2019
@w0rp
Copy link
Member

w0rp commented Jan 3, 2019

Cheers! 🍻

@davidvandebunte
Copy link

It looks like there were some regressions with this patch. As mentioned on #2131, we shouldn't be passing -o and other flags through this parsing step.

I'm manually testing immediately before and after this change by adding an echo l:cflags_list at the end of ale#c#ParseCFlags and it looks like most flags (including -o) are being passed through as a result of this change. Is anyone else seeing the same?

@w0rp
Copy link
Member

w0rp commented Jan 8, 2019

If there are regressions, it's because there weren't enough tests. The author of that other PR should add more tests and cover everything.

@fx-carton
Copy link
Contributor Author

I don't. I tested with my Makefiles which include -o flags, and I didn't see them in the results. Do you have an example where it passes a -o flag?

I took a look at the PR you linked, and I think it doesn't handle the cases where the argument contains spaces.

@davidvandebunte
Copy link

Here's an example:
/usr/bin/c++ -DAWS_SDK_VERSION_MAJOR=1 -DAWS_SDK_VERSION_MINOR=5 -DAWS_SDK_VERSION_PATCH=15 -DBOOST_LOG_DYN_LINK -DBOOST_NETWORK_ENABLE_HTTPS -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_SQL_LIB -DQT_WIDGETS_L IB -DRAPIDJSON_HAS_STDSTRING=1 -DRealWorldObjectsToolsLib_EXPORTS -DvtkDomainsChemistry_AUTOINIT="1(vtkDomainsChemistryOpenGL2)" -DvtkIOExport_AUTOINIT="1(vtkIOExportOpenGL2)" -DvtkRenderingContext2D_AUTOINIT="1 (vtkRenderingContextOpenGL2)" -DvtkRenderingCore_AUTOINIT="3(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingOpenGL2)" -DvtkRenderingOpenGL2_AUTOINIT="1(vtkRenderingGL2PSOpenGL2)" -DvtkRenderingVolume_AUTOI NIT="1(vtkRenderingVolumeOpenGL2)" -I/home/vandebun/lg/LocalizationGeometry/HDMA/HDRLibrary/RealWorldObjects/Tools/ToolImplementations/include -I/home/vandebun/lg/LocalizationGeometry/HDMA/HDRLibrary/RealWorldOb jects/Tools/ToolImplementations/src -I/home/vandebun/lg/LocalizationGeometry/HDMA/HDRLibrary/RealWorldObjects/include -I/home/vandebun/lg/LocalizationGeometry/HDMA/HDRLibrary/Core -I/home/vandebun/lg/Localizatio nGeometry/HDMA/HDRLibrary -I/home/vandebun/lg/LocalizationGeometry/HDMA/HDRLibrary/Geometry -I/home/vandebun/lg/LocalizationGeometry/HDMA/HDRLibrary/EarthCore -isystem /home/vande bun/lg/HDMA-EXT/Install/include/vtk-8.1 -isystem /home/vandebun/lg/HDMA-EXT/Install/include -isystem /home/vandebun/lg/HDMA-EXT/Install/include/pcl-1.8 -isystem /home/vandebun/lg/HDMA-EXT/Install/include/eigen3 -isystem /home/vandebun/lg/HDMA-EXT/Install/include/QtWidgets -isystem /home/vandebun/lg/HDMA-EXT/Install/include/QtGui -isystem /home/vandebun/lg/HDMA-EXT/Install/include/QtCore -isystem /home/vandebun/lg/HDMA- EXT/Install/./mkspecs/linux-g++ -isystem /home/vandebun/lg/HDMA-EXT/Install/include/QtSql -isystem /home/vandebun/lg/HDMA-EXT/Install/opencv3/include -isystem /home/vandebun/lg/HDMA-EXT/Install/opencv3/include/o pencv -isystem HDMA/ama-reader/include -Wall -Wextra -fPIC -fopenmp -fopenmp -Werror -O2 -g -DNDEBUG -fPIC -fPIC -std=c++1z -o HDMA/HDRLibrary/RealWorldObjects/Tools/ToolImplementations/CMakeFiles/RealWorldO bjectsToolsLib.dir/src/WriteNewAlignmentPointShifts.cpp.o -c /home/vandebun/lg/LocalizationGeometry/HDMA/HDRLibrary/RealWorldObjects/Tools/ToolImplementations/src/WriteNewAlignmentPointShifts.cpp

It looks like it goes into the if on line 77 of ale#c#ParseCFlags every time until it's stopped by l:option_index < len(l:split_lines) (by that point it has read in the -o flag).

@fx-carton fx-carton mentioned this pull request Jan 9, 2019
@fx-carton
Copy link
Contributor Author

Thanks, I can reproduce the bug with your example. The issue was with the matching of shell special characters. It should be fixed with #2194.

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

Successfully merging this pull request may close these issues.

g:ale_c_parse_makefile doesn't work properly
3 participants