-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Add compiler switches replace dangerous function with safer ones. #5089
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
src/libpsl-native/CMakeLists.txt
Outdated
| # Can't use add_compile_options with 2.8.11 | ||
| set(CMAKE_BUILD_TYPE "Release") | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror -fstack-protector-strong -fpie") | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror -fstack-protector-strong -fpie -DFORTIFY_SOURCE=2") |
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.
Based on the documentation, FORTIFY_SOURCE=2 isn't enabled unless you also use -O2 optimizations
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.
Resolved.
src/libpsl-native/CMakeLists.txt
Outdated
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror -fstack-protector-strong -fpie -DFORTIFY_SOURCE=2 -O2") | ||
|
|
||
| if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") | ||
| set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,relro,-z,now") |
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.
Will CMAKE_SYSTEM_NAME ever be set to 'Windows'?
Can you please share some resources where I can find what each of those options is for?
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.
This component isn't built for Windows. The Windows flags should go in ...\src\powershell-native\coreclr_defs.cmake.
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.
This Windows section should be removed
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.
Removed the windows case.
The docs are here:
https://cmake.org/cmake/help/v3.4/variable/CMAKE_HOST_SYSTEM_NAME.html#variable:CMAKE_HOST_SYSTEM_NAME
and
https://cmake.org/cmake/help/v3.4/variable/CMAKE_SYSTEM_NAME.html
BTW, we use this when compiling for ARM, set(CMAKE_SYSTEM_NAME Linux).
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.
@TravisEz13 Thanks. I'm actually interested in the options like -Wl,-z,relro,-z,now, and would like to know what they mean. I quickly search them bug didn't find anything very useful.
It will be great if you can provide some pointers. And better, put the link in CMakeLists.txt as comments.
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 about the other aspect of my comment? Are there corresponding flags that we can or should use with MSBuild when compiling pwrshplugin.dll?
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 have another work item to run the scan that would detect these type of issues. I just merged a change to the build to give me the data to run the scan. I should have it done Monday.
|
@daxian-dbw Can you update your review? |
daxian-dbw
left a comment
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.
It would be great if you add comments about some links that has information about the options used here, like -Wl,-z,relro,-z,now
|
I'll likely be making more changes. I'll include the detail where the tools give me them. |
This should fix #4975