Skip to content

jsrt: cleanup CHAKRACOREBUILD_ symbol in headers #3400

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

Merged
merged 1 commit into from
Jul 24, 2017

Conversation

jianchun
Copy link

@jianchun jianchun commented Jul 20, 2017

CHAKRACOREBUILD_ symbol should not be defined in ChakraCommon.h. The
later is included by Chakra JSRT (Windows 10 SDK) and would thus
incorrectly define CHAKRACOREBUILD_ and expose ChakraCore APIs (Note
that NTBUILD is not defined when a user includes Windows SDK headers).

Move the def to ChakraCore.h to solve this problem. Normally including
ChakraCore.h means using ChakraCore only APIs. (We define the symbol
only when !NTBUILD because of one exception -- shared implementation
Jsrt.cpp includes ChakraCore.h.)

Moved #ifdef CHAKRACOREBUILD_ to top of file to enclose all recent new
ChakraCore APIs, to help ensure those APIs not defined/exposed to Chakra.

Lastly renamed all CHAKRACOREBUILD_ to _CHAKRACOREBUILD. Use this one
symbol to differentiate ChakraCore APIs and implementations.

@jianchun
Copy link
Author

@curtisman @obastemur As I'm limiting/deprecating the other use of _CHAKRACOREBUILD, we can actually merge this one (CHAKRACOREBUILD_) to use the same symbol. Do you know of any reason to keep using a different one here? If not, I'm thinking to replace all CHAKRACOREBUILD_ with _CHAKRACOREBUILD, so that we'll use only one symbol to identify ChakraCore APIs and ChakraCore builds.

@agarwal-sandeep Questions:

  • I left ChakraDebug.h out of my #ifdef, because the related implementations are not strictly excluded from Chakra builds. If it is inside, then a bunch of JSRT debugging related code/files need to add #ifdef _CHAKRACOREBUILD to be ChakraCore exclusive. Would be noisy but maybe a good change to not leave unused code in Chakra?
  • What was the intended include sequence for ChakraDebug.h? Looks users should just include ChakraCore.h, then ChakraDebug.h should not include ChakraCommon.h.

@@ -1607,6 +1608,7 @@ CHAKRA_API JsReleaseSharedArrayBufferContentHandle(_In_ JsSharedArrayBufferConte
return JsNoError;
});
}
#endif // _CHAKRACOREBUILD
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: commented definition doesn't match.

@agarwal-sandeep
Copy link
Collaborator

@jianchun initially when JsRT debugging code was written we didn't had ChakraCore specific APIs (the plan was to have them in chakra build as well) but now I think we should limit it to ChakraCore only. This should give some binary size reduction in chakra as well.
If we make debugging APIs ChakraCore specific then ChakraDebug.h should not include ChakraCommon.h.


In reply to: 316569321 [](ancestors = 316569321)

@jianchun
Copy link
Author

jianchun commented Jul 20, 2017

@obastemur Thanks for review! Do you recall the reason of adding CHAKRACOREBUILD_ previously when we had _CHAKRACOREBUILD? Was it because _CHAKRACOREBUILD was misused (we had actually defined it for both ChakraCore and Chakra, so it didn't work)? If so, that problem is now resolved. I am considering to:

  1. Replace all CHAKRACOREBUILD_ with _CHAKRACOREBUILD. One symbol in future.
  2. Add _CHAKRACOREBUILD to top-level CMakeLists.txt so it is always defined for ChakraCore (consistent to Windows build where we define it in default VS props).

`CHAKRACOREBUILD_` symbol should not be defined in `ChakraCommon.h`. The
later is included by Chakra JSRT (Windows 10 SDK) and would thus
incorrectly define `CHAKRACOREBUILD_` and expose ChakraCore APIs (Note
that `NTBUILD` is not defined when a user includes Windows SDK headers).

Move the def to `ChakraCore.h` to solve this problem. Normally including
`ChakraCore.h` means using ChakraCore only APIs. (We define the symbol
only when `!NTBUILD` because of one exception -- shared implementation
`Jsrt.cpp` includes `ChakraCore.h`.)

Moved `#ifdef CHAKRACOREBUILD_` to top of file to enclose all recent new
ChakraCore APIs, to help ensure those APIs not defined/exposed to Chakra.

Lastly renamed all `CHAKRACOREBUILD_` to `_CHAKRACOREBUILD`. Use this one
symbol to differentiate ChakraCore APIs and implementations.
@obastemur
Copy link
Collaborator

LGTM. @jianchun Thanks for fixing this!

@jianchun
Copy link
Author

@obastemur Thanks for review!

@chakrabot chakrabot merged commit cf1e46c into chakra-core:release/1.6 Jul 24, 2017
chakrabot pushed a commit that referenced this pull request Jul 24, 2017
Merge pull request #3400 from jianchun:ccblddef

`CHAKRACOREBUILD_` symbol should not be defined in `ChakraCommon.h`. The
later is included by Chakra JSRT (Windows 10 SDK) and would thus
incorrectly define `CHAKRACOREBUILD_` and expose ChakraCore APIs (Note
that `NTBUILD` is not defined when a user includes Windows SDK headers).

Move the def to `ChakraCore.h` to solve this problem. Normally including
`ChakraCore.h` means using ChakraCore only APIs. (We define the symbol
only when `!NTBUILD` because of one exception -- shared implementation
`Jsrt.cpp` includes `ChakraCore.h`.)

Moved `#ifdef CHAKRACOREBUILD_` to top of file to enclose all recent new
ChakraCore APIs, to help ensure those APIs not defined/exposed to Chakra.

Lastly renamed all `CHAKRACOREBUILD_` to `_CHAKRACOREBUILD`. Use this one
symbol to differentiate ChakraCore APIs and implementations.
@jianchun jianchun deleted the ccblddef branch July 24, 2017 16:25
chakrabot pushed a commit that referenced this pull request Jul 24, 2017
…ol in headers

Merge pull request #3400 from jianchun:ccblddef

`CHAKRACOREBUILD_` symbol should not be defined in `ChakraCommon.h`. The
later is included by Chakra JSRT (Windows 10 SDK) and would thus
incorrectly define `CHAKRACOREBUILD_` and expose ChakraCore APIs (Note
that `NTBUILD` is not defined when a user includes Windows SDK headers).

Move the def to `ChakraCore.h` to solve this problem. Normally including
`ChakraCore.h` means using ChakraCore only APIs. (We define the symbol
only when `!NTBUILD` because of one exception -- shared implementation
`Jsrt.cpp` includes `ChakraCore.h`.)

Moved `#ifdef CHAKRACOREBUILD_` to top of file to enclose all recent new
ChakraCore APIs, to help ensure those APIs not defined/exposed to Chakra.

Lastly renamed all `CHAKRACOREBUILD_` to `_CHAKRACOREBUILD`. Use this one
symbol to differentiate ChakraCore APIs and implementations.
chakrabot pushed a commit that referenced this pull request Jul 24, 2017
…REBUILD_ symbol in headers

Merge pull request #3400 from jianchun:ccblddef

`CHAKRACOREBUILD_` symbol should not be defined in `ChakraCommon.h`. The
later is included by Chakra JSRT (Windows 10 SDK) and would thus
incorrectly define `CHAKRACOREBUILD_` and expose ChakraCore APIs (Note
that `NTBUILD` is not defined when a user includes Windows SDK headers).

Move the def to `ChakraCore.h` to solve this problem. Normally including
`ChakraCore.h` means using ChakraCore only APIs. (We define the symbol
only when `!NTBUILD` because of one exception -- shared implementation
`Jsrt.cpp` includes `ChakraCore.h`.)

Moved `#ifdef CHAKRACOREBUILD_` to top of file to enclose all recent new
ChakraCore APIs, to help ensure those APIs not defined/exposed to Chakra.

Lastly renamed all `CHAKRACOREBUILD_` to `_CHAKRACOREBUILD`. Use this one
symbol to differentiate ChakraCore APIs and implementations.
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.

5 participants