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

Improve compatibility with Dinkumware C++ headers #1008

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

matthargett
Copy link

Summary:
These are a set of minor changes to allow building and linking on older clang and toolchains that use Dinkumware headers. I adjusted and tested only the subset of folly used by React Native's CxxReact, Fabric, and TurboModules C++ sources.

Test plan:
I ran the build on my Ubuntu 18.x using both clang 3.9, clang 6.x, and GCC 8.x. I couldn't find a way to build and run the unit tests in cmake, so I spot checked several unit tests with a manual CLI build:
g++-8 -I ../vcpkg/installed/x64-linux/include/ -L../vcpkg/installed/x64-linux/lib -I. -I_build folly/test/DynamicConverterTest.cpp folly/test/common/TestMain.cpp -lgtest -lpthread -lglog -lgflags -ldouble-conversion -lssl -lboost_filesystem -lboost_program_options -lboost_regex -lboost_system -ldl -lstdc++ -liberty _build/libfolly.a ../vcpkg/installed/x64-linux/lib/libdouble-conversion.a

@matthargett
Copy link
Author

@mhorowitz this is the folly side of facebook/react-native#21764

@matthargett
Copy link
Author

Looks like the build is failing for unrelated reasons (can't persist the ccache after the build finished successfully).

folly/ExceptionWrapper.h Outdated Show resolved Hide resolved
folly/Portability.h Outdated Show resolved Hide resolved
folly/detail/RangeSse42.cpp Outdated Show resolved Hide resolved
folly/portability/PThread.h Outdated Show resolved Hide resolved
@yfeldblum
Copy link
Contributor

To give some perspective, overall, we are not planning to support older versions of compilers. This includes clang 3.9 and msvc 2015.

As one particular, clang 3.9 has no support for C++17, so that compiler will definitely not work once we decide to jump to C++17.

We also want to avoid all the extra complexity, preprocessor conditionals, restrictions on coding patterns, etc., that arise from supporting older compilers.

@matthargett matthargett changed the title Improve compatibility with older clang and Dinkumware C++ headers Improve compatibility with Dinkumware C++ headers Feb 25, 2019
@matthargett
Copy link
Author

@yfeldblum sorry, my title was misleading. This is with clang 6 and 7, but using Dinkumware headers.

I was able to bump the Dinkumware headers and eliminate a bunch of the __has_include noise. Take another look and let me know what you think.

Copy link
Contributor

@yfeldblum yfeldblum left a comment

Choose a reason for hiding this comment

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

Can you clarify which versions of cpplib you are intending compatibility with?

folly/Portability.h Outdated Show resolved Hide resolved
folly/Portability.h Outdated Show resolved Hide resolved
folly/String.cpp Outdated Show resolved Hide resolved
folly/Traits.h Outdated Show resolved Hide resolved
folly/dynamic-inl.h Outdated Show resolved Hide resolved
folly/memory/Malloc.h Outdated Show resolved Hide resolved
folly/system/ThreadId.h Outdated Show resolved Hide resolved
folly/FBString.h Outdated Show resolved Hide resolved
folly/Conv.h Outdated Show resolved Hide resolved
folly/Portability.h Outdated Show resolved Hide resolved
@yfeldblum
Copy link
Contributor

Note that when PRs are imported into the internal code review tool or landed into the repo, the PR commits are squashed into a single commit.

folly/system/ThreadId.h Outdated Show resolved Hide resolved
@@ -23,6 +23,10 @@
#include <folly/portability/Unistd.h>
#include <folly/portability/Windows.h>

#if __has_include(<pthread_np.h>)
#include <pthread_np.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

@Orvid Do we want this include here or in the portability header?

@matthargett
Copy link
Author

Looks like the build failure is an unrelated regression caused by a different commit?

/home/folly/folly/small_vector.h:739:32: error: 'malloc_usable_size' was not declared in this scope
       return malloc_usable_size(u.pdata_.heap_) / sizeof(value_type);```

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@yfeldblum has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@yfeldblum
Copy link
Contributor

Note that I will internally reorder the glog includes to match our style.

@matthargett
Copy link
Author

any issues landing it in phabricator? let me know if there's anything else I can do to get it merged.

// are found in stdlib.h.
#if __has_include(<malloc.h>)
// are found in stdlib.h and it errors when including malloc.h.
#if __has_include(<malloc.h>) && (!defined(__STDC__) || !__STDC__)
Copy link
Contributor

Choose a reason for hiding this comment

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

This (or the change to the portability malloc below) is causing malloc.h to no longer get included in our internal builds :(

If these two changes are dropped, the rest should be safe to land :)

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

Successfully merging this pull request may close these issues.

None yet

4 participants