Skip to content

Stack smashing protection causing issues with Windows targets #12

@FrancisRussell

Description

@FrancisRussell

I've been using audiopus_sys 0.2.2 via audiopus 0.3.0-rc.0, In my Cargo.toml, I've used the static option to ensure that libopus is built from source. In an Ubuntu environment I've been cross compiling my project for the x86_64-pc-windows-gnu and i686-pc-windows-gnu targets. However, I have encountered linking issues due to stack-smashing protection (SSP). These manifest as follows:

  = note: /target/i686-pc-windows-gnu/debug/deps/libaudiopus_sys-b661dfe0e9f65081.rlib(opus_decoder.c.obj): In function `opus_decoder_get_size':
          /cargo/registry/src/github.com-1ecc6299db9ec823/audiopus_sys-0.2.2/opus/src/opus_decoder.c:103: undefined reference to `__stack_chk_guard'
          /cargo/registry/src/github.com-1ecc6299db9ec823/audiopus_sys-0.2.2/opus/src/opus_decoder.c:114: undefined reference to `__stack_chk_guard'
          /cargo/registry/src/github.com-1ecc6299db9ec823/audiopus_sys-0.2.2/opus/src/opus_decoder.c:114: undefined reference to `__stack_chk_fail'
          /target/i686-pc-windows-gnu/debug/deps/libaudiopus_sys-b661dfe0e9f65081.rlib(opus_decoder.c.obj): In function `opus_decoder_init':
          /cargo/registry/src/github.com-1ecc6299db9ec823/audiopus_sys-0.2.2/opus/src/opus_decoder.c:117: undefined reference to `__stack_chk_guard'
          /cargo/registry/src/github.com-1ecc6299db9ec823/audiopus_sys-0.2.2/opus/src/opus_decoder.c:157: undefined reference to `__stack_chk_guard'
          /cargo/registry/src/github.com-1ecc6299db9ec823/audiopus_sys-0.2.2/opus/src/opus_decoder.c:157: undefined reference to `__stack_chk_fail'
          /target/i686-pc-windows-gnu/debug/deps/libaudiopus_sys-b661dfe0e9f65081.rlib(opus_decoder.c.obj): In function `opus_decode_frame':
          /cargo/registry/src/github.com-1ecc6299db9ec823/audiopus_sys-0.2.2/opus/src/opus_decoder.c:222: undefined reference to `__stack_chk_guard'
          /cargo/registry/src/github.com-1ecc6299db9ec823/audiopus_sys-0.2.2/opus/src/opus_decoder.c:624: undefined reference to `__stack_chk_guard'
          /cargo/registry/src/github.com-1ecc6299db9ec823/audiopus_sys-0.2.2/opus/src/opus_decoder.c:624: undefined reference to `__stack_chk_fail'

From what I can tell, the Opus library will compile using SSP functionality by default which is what causes these references. I was able to work around the issue by creating a .cargo/config.toml as follows:

[target.x86_64-pc-windows-gnu]
rustflags = [ "-C", "link-arg=-lssp" ]

[target.i686-pc-windows-gnu]
rustflags = [ "-C", "link-arg=-lssp" ]

I also have a build for x86-64 musl, but did not encounter this issue.

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