packages feed

cabal-buck2-0.6.0.0: buck2/prelude/ide_integrations/visual_studio/ppflags.bxl

# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is dual-licensed under either the MIT license found in the
# LICENSE-MIT file in the root directory of this source tree or the Apache
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
# of this source tree. You may select, at your option, one of the
# above-listed licenses.

# Source: https://learn.microsoft.com/en-us/visualstudio/msbuild/cl-task?view=vs-2022
COMPILER_FLAGS_MAP = {
    "/EHa": [("ExceptionHandling", "Async")],
    "/EHs": [("ExceptionHandling", "SyncCThrow")],
    "/EHsc": [("ExceptionHandling", "Sync")],
    "/FC": [("UseFullPaths", "true")],
    "/GF": [("StringPooling", "true")],
    "/GF-": [("StringPooling", "false")],
    "/GR": [("RuntimeTypeInfo", "true")],
    "/GS": [("BufferSecurityCheck", "true")],
    "/GS-": [("BufferSecurityCheck", "false")],
    "/Gd": [("CallingConvention", "Cdecl")],
    "/Gm": [("MinimalRebuild", "true")],
    "/Gm-": [("MinimalRebuild", "false")],
    "/Gr": [("CallingConvention", "FastCall")],
    "/Gy": [("FunctionLevelLinking", "true")],
    "/Gy-": [("FunctionLevelLinking", "false")],
    "/Gz": [("CallingConvention", "StdCall")],
    "/MD": [("RuntimeLibrary", "MultiThreadedDLL")],
    "/MDd": [("RuntimeLibrary", "MultiThreadedDebugDLL")],
    "/MP": [("MultiProcessorCompilation", "true")],
    "/MT": [("RuntimeLibrary", "MultiThreaded")],
    "/MTd": [("RuntimeLibrary", "MultiThreadedDebug")],
    "/O0": [("Optimization", "Disabled")],
    "/O1": [("Optimization", "MinSpace")],
    "/O2": [("Optimization", "MaxSpeed")],
    "/O3": [("Optimization", "Full")],
    "/Ob0": [("InlineFunctionExpansion", "Disabled")],
    "/Ob1": [("InlineFunctionExpansion", "OnlyExplicitInline")],
    "/Ob2": [("InlineFunctionExpansion", "AnySuitable")],
    "/Od": [("Optimization", "Disabled")],
    "/Oi": [("IntrinsicFunctions", "true")],
    "/Oi-": [("IntrinsicFunctions", "false")],
    "/Ox": [("Optimization", "Full")],
    "/Oy": [("OmitFramePointers", "true")],
    "/Oy-": [("OmitFramePointers", "false")],
    "/RTC1": [("BasicRuntimeChecks", "EnableFastChecks")],
    "/RTCs": [("BasicRuntimeChecks", "StackFrameRuntimeCheck")],
    "/RTCu": [("BasicRuntimeChecks", "UninitializedLocalUsageCheck")],
    "/TP": [("CompileAs", "CompileAsCpp")],
    "/W0": [("WarningLevel", "TurnOffAllWarnings")],
    "/W1": [("WarningLevel", "Level1")],
    "/W2": [("WarningLevel", "Level2")],
    "/W3": [("WarningLevel", "Level3")],
    "/W4": [("WarningLevel", "Level4")],
    "/WX": [("TreatLinkerWarningAsErrors", "true")],
    "/WX-": [("TreatLinkerWarningAsErrors", "false")],
    "/Wall": [("WarningLevel", "EnableAllWarnings")],
    "/Werror": [("TreatLinkerWarningAsErrors", "true")],
    "/Z7": [("DebugInformationFormat", "OldStyle")],
    "/ZI": [("DebugInformationFormat", "EditAndContinue")],
    "/Zc:forScope": [("ForceConformanceInForLoopScope", "true")],
    "/Zc:forScope-": [("ForceConformanceInForLoopScope", "false")],
    "/Zc:wchar_t": [("TreatWChar_tAsBuiltInType", "true")],
    "/Zc:wchar_t-": [("TreatWChar_tAsBuiltInType", "false")],
    "/Zi": [("DebugInformationFormat", "ProgramDatabase")],
    "/Zp4": [("StructMemberAlignment", "4Bytes")],
    "/arch:AVX": [("EnableEnhancedInstructionSet", "AdvancedVectorExtensions")],
    "/arch:AVX2": [("EnableEnhancedInstructionSet", "AdvancedVectorExtensions2")],
    "/arch:AVX512": [("EnableEnhancedInstructionSet", "AdvancedVectorExtensions512")],
    "/arch:IA32": [("EnableEnhancedInstructionSet", "NoExtensions")],
    "/arch:SSE": [("EnableEnhancedInstructionSet", "StreamingSIMDExtensions")],
    "/arch:SSE2": [("EnableEnhancedInstructionSet", "StreamingSIMDExtensions2")],
    "/errorReport:none": [("ErrorReporting", "None")],
    "/errorReport:prompt": [("ErrorReporting", "Prompt")],
    "/errorReport:queue": [("ErrorReporting", "Queue")],
    "/errorReport:send": [("ErrorReporting", "Send")],
    "/fcxx-exceptions": [("ExceptionHandling", "Sync")],
    "/fexceptions": [("ExceptionHandling", "Sync")],
    "/ffast-math": [("FloatingPointModel", "Fast")],
    "/fno-exceptions": [("ExceptionHandling", "false")],
    "/fno-omit-frame-pointer": [("OmitFramePointers", "false")],
    "/fomit-frame-pointer": [("OmitFramePointers", "true")],
    "/fp:fast": [("FloatingPointModel", "Fast")],
    "/fp:precise": [("FloatingPointModel", "Precise")],
    "/fp:strict": [("FloatingPointModel", "Strict")],
    "/frtti": [("RuntimeTypeInfo", "true")],
    "/fstack-protector": [("BufferSecurityCheck", "true")],
    "/fstack-protector-all": [("BufferSecurityCheck", "true")],
    "/fstack-protector-explicit": [("BufferSecurityCheck", "true")],
    "/fstack-protector-strong": [("BufferSecurityCheck", "true")],
    "/mno-omit-leaf-frame-pointer": [("OmitFramePointers", "false")],
    "/nologo": [("SuppressStartupBanner", "true")],
    "/openmp": [("OpenMPSupport", "true")],
}

COMPILER_IGNORE_OPTIONS = [
    "/g",
    "/nostdinc",
    "/nostdlib",
    "/fdiagnostics-format=msvc",
    "/gcodeview",
    "/flto-visibility-public-std",
    "/Xclang",
    "/mfma",
    "/mrtm",
]

# Source: https://learn.microsoft.com/en-us/visualstudio/msbuild/link-task?view=vs-2022
LINKER_FLAGS_MAP = {
    "/DEBUG": [("GenerateDebugInformation", "true")],
    "/DEBUG:FASTLINK": [("GenerateDebugInformation", "true")],
    "/DEBUG:FULL": [("GenerateDebugInformation", "true")],
    "/DEBUG:NONE": [("GenerateDebugInformation", "false")],
    "/DYNAMICBASE": [("RandomizedBaseAddress", "true")],
    "/DYNAMICBASE:NO": [("RandomizedBaseAddress", "false")],
    "/ENTRY:MAINCRTSTARTUP": [("EntryPointSymbol", "mainCRTStartup")],
    "/G": [("GenerateDebugInformation", "true")],
    "/INCREMENTAL": [("LinkIncremental", "true")],
    "/INCREMENTAL:NO": [("LinkIncremental", "false")],
    "/LTCG": [("LinkTimeCodeGeneration", "UseLinkTimeCodeGeneration")],
    "/LTCG:PGInstrument": [("LinkTimeCodeGeneration", "PGInstrument")],
    "/LTCG:PGOptimize": [("LinkTimeCodeGeneration", "PGOptimization")],
    "/LTCG:PGUpdate": [("LinkTimeCodeGeneration", "PGUpdate")],
    "/MACHINE:X64": [("TargetMachine", "MachineX64")],
    "/MANIFEST": [("GenerateManifest", "true")],
    "/MANIFEST:NO": [("GenerateManifest", "false")],
    "/NXCOMPAT": [("DataExecutionPrevention", "true")],
    "/NXCOMPAT:NO": [("DataExecutionPrevention", "false")],
    "/OPT:ICF": [("EnableCOMDATFolding", "true")],
    "/OPT:NOICF": [("EnableCOMDATFolding", "false")],
    "/OPT:NOREF": [("OptimizeReferences", "false")],
    "/OPT:REF": [("OptimizeReferences", "true")],
    "/SAFESEH": [("ImageHasSafeExceptionHandlers", "true")],
    "/SAFESEH:NO": [("ImageHasSafeExceptionHandlers", "false")],
    "/SUBSYSTEM:CONSOLE": [("SubSystem", "Console")],
    "/SUBSYSTEM:NATIVE": [("SubSystem", "Windows")],
    "/SUBSYSTEM:WINDOWS": [("SubSystem", "Native")],
    "/fPIE": [("RandomizedBaseAddress", "true")],
    "/fpie": [("RandomizedBaseAddress", "true")],
    "/pie": [("RandomizedBaseAddress", "true")],
}

# @unsorted-dict-items
LANGUAGE_STANDARD_MAP = {
    # stdcpp17
    "/std:c++17": "stdcpp17",
    "/std=gnu++17": "stdcpp17",
    "/std=c++17": "stdcpp17",
    # stdcpp20
    "/std:c++20": "stdcpp20",
    "/std=gnu++20": "stdcpp20",
    "/std=c++20": "stdcpp20",
    # stdcpplatest
    "/std:c++latest": "stdcpplatest",
    "/std=gnu++latest": "stdcpplatest",
    "/std=c++latest": "stdcpplatest",
}