Skip to content

Platform detection in setenvvar.bat always fails and forces x64 #8865

@tomneko

Description

@tomneko

Summary

The Windows build of Firebird 3.0.13, 4.0.6, and 5.0.3 cannot reliably detect
the correct target platform on modern Visual Studio environments due to
incorrect logic in setenvvar.bat. This prevents proper Win32/Win64
separation and causes the build system to behave incorrectly.

This issue was observed while using Microsoft Visual Studio 2022 Build Tools.

Problem Details

setenvvar.bat determines the target platform using the
PROCESSOR_ARCHITECTURE environment variable.
However, with VS2022 Build Tools, PROCESSOR_ARCHITECTURE always reports
AMD64 even when using the x86 Native Tools Command Prompt.

As a result:

  • FB_TARGET_PLATFORM is always set to x64
  • FB_OUTPUT_DIR always points to output_x64
  • clean_all removes the wrong output directory
  • Win32 builds do not behave correctly because the environment is misconfigured

This behavior was verified on:

  • Firebird 3.0.13
  • Firebird 4.0.6
  • Firebird 5.0.3

Expected Behavior

When using the x86 Native Tools Command Prompt,
FB_TARGET_PLATFORM should be set to Win32, and the build system should
produce valid Win32 output directories and behave consistently.

Proposed Fix

Use the %Platform% environment variable provided by Visual Studio instead of
PROCESSOR_ARCHITECTURE.
%Platform% correctly reports x86 or x64 depending on the toolchain
invoked, and works consistently with VS2022 Build Tools.

I will submit a pull request with this fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions