How to enable '-fdeclspec' or '-fms-extensions' compiler options to compile C++ source code in project?

I’m trying to have C++ source code in my project compiled when I build it instead of having a library instead to avoid the performance costs of P/Invoke.

Following the instructions here:

I’ve got the C++ code in Assets/Plugins/Mac/x86_64/NativeFunctions.cpp and the import settings set to Standalone/Mac OS X x64.

When I try to build and run I get this error (and warning):

[ERROR] FATAL UNHANDLED EXCEPTION: Unity.IL2CPP.Building.BuilderFailedException: /Users/....../project/Temp/StagingArea/Data/il2cppOutput/NativeFunctions.cpp:1:15: error: '__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes
<U+FEFF>extern "C" __declspec(dllexport) int __stdcall CountLettersInString(wchar_t* str)
                   ^
/Users/...../project/Temp/StagingArea/Data/il2cppOutput/NativeFunctions.cpp:1:41: warning: '__stdcall' calling convention is not supported for this target [-Wignored-attributes]
<U+FEFF>extern "C" __declspec(dllexport) int __stdcall CountLettersInString(wchar_t* str)
                                             ^
1 warning and 1 error generated.

I’m using Unity 2020.1.8f1 on OS X 10.15.7.

Is there anyway I’m able to customize the compiler’s arguments? Specifically so I can add -fdeclspec to the clang++ invocation.

Hi
Thanks for the reply.

Quoting from the link above;

This significantly decreases the performance overhead of a P/Invoke call.

Am I misunderstanding something?