pingcap / tiflash

The analytical engine for TiDB and TiDB Cloud. Try free: https://tidbcloud.com/free-trial
https://docs.pingcap.com/tidb/stable/tiflash-overview
Apache License 2.0
937 stars 409 forks source link

*: Fix compile error under macos #9102

Closed JaySon-Huang closed 1 month ago

JaySon-Huang commented 1 month ago

What problem does this PR solve?

Issue Number: close https://github.com/pingcap/tiflash/issues/9101, ref https://github.com/pingcap/tiflash/issues/8835

Problem Summary:

Introduce by https://github.com/pingcap/tiflash/pull/9064

The signature of je_mallctl is

int mallctl(    const char *name,
    void *oldp,
    size_t *oldlenp,
    void *newp,
    size_t newlen);

But we pass a uint64_t * for oldlenp.

'uint64_t' is 'unsigned long long ' while 'size_t' is 'unsigned long' under MacOS, that cause the following compile error

/Users/pingcap/workspace/bp-tiflash-release-darwin-arm64-dnmfl-build-binaries/source/tiflash/dbms/src/Common/MemoryAllocTrace.cpp:32:5: error: no matching function for call to 'je_mallctl'
    je_mallctl("thread.deallocatedp", reinterpret_cast<void *>(&ptr2), &size2, nullptr, 0);
    ^~~~~~~~~~
/Users/pingcap/workspace/bp-tiflash-release-darwin-arm64-dnmfl-build-binaries/source/tiflash/release-darwin/build-release/contrib/jemalloc-cmake/include/jemalloc/jemalloc_rename.h:11:20: note: expanded from macro 'je_mallctl'
#define je_mallctl je_mallctl
                   ^~~~~~~~~~
/Users/pingcap/workspace/bp-tiflash-release-darwin-arm64-dnmfl-build-binaries/source/tiflash/contrib/jemalloc-cmake/include/jemalloc/jemalloc_protos.h:53:38: note: candidate function not viable: no known conversion from 'uint64_t *' (aka 'unsigned long long *') to 'size_t *' (aka 'unsigned long *') for 3rd argument
JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_mallctl(const char * name,
                                     ^
/Users/pingcap/workspace/bp-tiflash-release-darwin-arm64-dnmfl-build-binaries/source/tiflash/release-darwin/build-release/contrib/jemalloc-cmake/include/jemalloc/jemalloc_rename.h:11:20: note: expanded from macro 'je_mallctl'
#define je_mallctl je_mallctl

What is changed and how it works?

Change the type from uint64_t to size_t for 3rd param of je_mallctl

Fix compile error under macos

Check List

Tests

Side effects

Documentation

Release note

None
JaySon-Huang commented 1 month ago

/hold wait for the manual mac build result

JaySon-Huang commented 1 month ago

/unhold Build success on mac

ti-chi-bot[bot] commented 1 month ago

[LGTM Timeline notifier]

Timeline:

ti-chi-bot[bot] commented 1 month ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CalvinNeo, JinheLin, Lloyd-Pottiger

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/pingcap/tiflash/blob/master/OWNERS)~~ [CalvinNeo,JinheLin,Lloyd-Pottiger] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment