Skip to content

Suggestion: Ease cross compiling, reduce reliance on env vars #13

Description

@4LT

I don't know if this would be in-scope for the project or not but...

I found it difficult to cross-compile from Linux to Windows. While possible, I think it could be more ergonomic.

The command I eventually landed on looks like this:

RUSTFLAGS="-L scratch/tcl-${tcl_tag}/win/build"\
    PKG_CONFIG_ALLOW_CROSS=1\
    BINDGEN_EXTRA_CLANG_ARGS='-D__int64="long long" -Dssize_t=int64_t'\
    cargo build --target=x86_64-pc-windows-gnu --release

Where scratch/tcl-${tcl_tag}/win/build is the relative path where I have tcl86.dll built. (Additionally, I have to create a symlink from tcl8.6.dll -> tcl86.dll for the tcl crate to find the lib, based on the default make behavior from the Tcl source.)

Ideally I'd like to be able to configure the path to the Tcl lib elsewhere and be able to just run cargo build --target=x86_64-pc-windows-gnu --release to build an executable.

In particular, the BINDGEN_EXTRA_CLANG_ARGS='-D__int64="long long" -Dssize_t=int64_t' bit is a bit silly, apparently some sort of clang behavior that deviates from GCC. (So far as I can tell, __int64 is only recognized by MSVC, although clang already appears to define __GNUC__ by default, so I have no idea why __int64 is reached).


I'd also like to say that you're bindings are working terrifically! I've had no problems with the code I've written to consume the tcl crate, and I've had reports that it's working under Windows (through a cross-compile build I've handed out) as well.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions