Csound Csound-dev Csound-tekno Search About

[Cs-dev] Issue with ms-bitfields on Windows (SF Bug - Platform Specific #4)

Date2014-02-20 22:33
FromSteven Yi
Subject[Cs-dev] Issue with ms-bitfields on Windows (SF Bug - Platform Specific #4)
Hi All,

After a bit of an exhaustive search, I found the root cause for the
sound font bug on Windows[1].  From [2], it turns out that using
__attribute__((packed)) with MinGW stopped working in gcc 4.7.0[3],
when -mms-bitfields was turned on by default. This caused the behavior
for packing of structs to change, and that in turn caused problems
with Soundfonts, where packing is required. As a test, I added
"-mno-ms-bitfields" to my Custom.cmake and running the test file I got
the correct results.

To note: This is *only* an issue on Windows.

Now, my concern here is how best to fix this.  I don't know what
effects ms-bitfields might have on the rest of the application. My
thought is that we only really use packing in the sfont code.  (I'm
working on trying to add the flag only when compiling the sfont.c
file, hopefully should work!)

There is some more information about the ms-bitfields at [4]:

[quote]

6.37.3 i386 Type Attributes

Two attributes are currently defined for i386 configurations:
ms_struct and gcc_struct.

ms_structgcc_structIf packed is used on a structure, or if bit-fields
are used it may be that the Microsoft ABI packs them differently than
GCC normally packs them. Particularly when moving packed data between
functions compiled with GCC and the native Microsoft compiler (either
via function call or as data in a file), it may be necessary to access
either format.

Currently -m[no-]ms-bitfields is provided for the Microsoft Windows
X86 compilers to match the native Microsoft compiler.

[endquote]

Once I get this cmake change done, I'll reply here and ask for
re-tests on the bug.

Thanks!
steven

[1] - https://sourceforge.net/p/csound/platformspecific/4/
[2] - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991
[3] - http://gcc.gnu.org/gcc-4.7/changes.html
[4] - http://gcc.gnu.org/onlinedocs/gcc-4.8.1/gcc/Type-Attributes.html

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-02-20 22:52
FromSteven Yi
SubjectRe: [Cs-dev] Issue with ms-bitfields on Windows (SF Bug - Platform Specific #4)
Hi All,

I just pushed a CMake change that uses -mno-ms-bitfields just with
sfont.c.  Could those on Windows do a re-test?

Thanks!
steven

On Thu, Feb 20, 2014 at 5:33 PM, Steven Yi  wrote:
> Hi All,
>
> After a bit of an exhaustive search, I found the root cause for the
> sound font bug on Windows[1].  From [2], it turns out that using
> __attribute__((packed)) with MinGW stopped working in gcc 4.7.0[3],
> when -mms-bitfields was turned on by default. This caused the behavior
> for packing of structs to change, and that in turn caused problems
> with Soundfonts, where packing is required. As a test, I added
> "-mno-ms-bitfields" to my Custom.cmake and running the test file I got
> the correct results.
>
> To note: This is *only* an issue on Windows.
>
> Now, my concern here is how best to fix this.  I don't know what
> effects ms-bitfields might have on the rest of the application. My
> thought is that we only really use packing in the sfont code.  (I'm
> working on trying to add the flag only when compiling the sfont.c
> file, hopefully should work!)
>
> There is some more information about the ms-bitfields at [4]:
>
> [quote]
>
> 6.37.3 i386 Type Attributes
>
> Two attributes are currently defined for i386 configurations:
> ms_struct and gcc_struct.
>
> ms_structgcc_structIf packed is used on a structure, or if bit-fields
> are used it may be that the Microsoft ABI packs them differently than
> GCC normally packs them. Particularly when moving packed data between
> functions compiled with GCC and the native Microsoft compiler (either
> via function call or as data in a file), it may be necessary to access
> either format.
>
> Currently -m[no-]ms-bitfields is provided for the Microsoft Windows
> X86 compilers to match the native Microsoft compiler.
>
> [endquote]
>
> Once I get this cmake change done, I'll reply here and ask for
> re-tests on the bug.
>
> Thanks!
> steven
>
> [1] - https://sourceforge.net/p/csound/platformspecific/4/
> [2] - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991
> [3] - http://gcc.gnu.org/gcc-4.7/changes.html
> [4] - http://gcc.gnu.org/onlinedocs/gcc-4.8.1/gcc/Type-Attributes.html

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-02-21 12:15
FromOeyvind Brandtsegg
SubjectRe: [Cs-dev] Issue with ms-bitfields on Windows (SF Bug - Platform Specific #4)
Tested here, and it works fine.
Also tested with the sf_GMbank.sf2 file distributed with Csound (in
Csound/samples),
and that works fine too (did segfault before this fix).
Thanks a lot for the effort!
Oeyvind

2014-02-20 23:52 GMT+01:00 Steven Yi :
> Hi All,
>
> I just pushed a CMake change that uses -mno-ms-bitfields just with
> sfont.c.  Could those on Windows do a re-test?
>
> Thanks!
> steven
>
> On Thu, Feb 20, 2014 at 5:33 PM, Steven Yi  wrote:
>> Hi All,
>>
>> After a bit of an exhaustive search, I found the root cause for the
>> sound font bug on Windows[1].  From [2], it turns out that using
>> __attribute__((packed)) with MinGW stopped working in gcc 4.7.0[3],
>> when -mms-bitfields was turned on by default. This caused the behavior
>> for packing of structs to change, and that in turn caused problems
>> with Soundfonts, where packing is required. As a test, I added
>> "-mno-ms-bitfields" to my Custom.cmake and running the test file I got
>> the correct results.
>>
>> To note: This is *only* an issue on Windows.
>>
>> Now, my concern here is how best to fix this.  I don't know what
>> effects ms-bitfields might have on the rest of the application. My
>> thought is that we only really use packing in the sfont code.  (I'm
>> working on trying to add the flag only when compiling the sfont.c
>> file, hopefully should work!)
>>
>> There is some more information about the ms-bitfields at [4]:
>>
>> [quote]
>>
>> 6.37.3 i386 Type Attributes
>>
>> Two attributes are currently defined for i386 configurations:
>> ms_struct and gcc_struct.
>>
>> ms_structgcc_structIf packed is used on a structure, or if bit-fields
>> are used it may be that the Microsoft ABI packs them differently than
>> GCC normally packs them. Particularly when moving packed data between
>> functions compiled with GCC and the native Microsoft compiler (either
>> via function call or as data in a file), it may be necessary to access
>> either format.
>>
>> Currently -m[no-]ms-bitfields is provided for the Microsoft Windows
>> X86 compilers to match the native Microsoft compiler.
>>
>> [endquote]
>>
>> Once I get this cmake change done, I'll reply here and ask for
>> re-tests on the bug.
>>
>> Thanks!
>> steven
>>
>> [1] - https://sourceforge.net/p/csound/platformspecific/4/
>> [2] - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991
>> [3] - http://gcc.gnu.org/gcc-4.7/changes.html
>> [4] - http://gcc.gnu.org/onlinedocs/gcc-4.8.1/gcc/Type-Attributes.html
>
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
> http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel



-- 

Oeyvind Brandtsegg
Professor of Music Technology
NTNU
7491 Trondheim
Norway
Cell: +47 92 203 205

http://flyndresang.no/
http://www.partikkelaudio.com/
http://soundcloud.com/brandtsegg
http://soundcloud.com/t-emp

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-02-21 14:20
FromSteven Yi
SubjectRe: [Cs-dev] Issue with ms-bitfields on Windows (SF Bug - Platform Specific #4)
AttachmentsNone  None  

Thanks for confirming!

On Feb 21, 2014 7:16 AM, "Oeyvind Brandtsegg" <oyvind.brandtsegg@ntnu.no> wrote:
Tested here, and it works fine.
Also tested with the sf_GMbank.sf2 file distributed with Csound (in
Csound/samples),
and that works fine too (did segfault before this fix).
Thanks a lot for the effort!
Oeyvind

2014-02-20 23:52 GMT+01:00 Steven Yi <stevenyi@gmail.com>:
> Hi All,
>
> I just pushed a CMake change that uses -mno-ms-bitfields just with
> sfont.c.  Could those on Windows do a re-test?
>
> Thanks!
> steven
>
> On Thu, Feb 20, 2014 at 5:33 PM, Steven Yi <stevenyi@gmail.com> wrote:
>> Hi All,
>>
>> After a bit of an exhaustive search, I found the root cause for the
>> sound font bug on Windows[1].  From [2], it turns out that using
>> __attribute__((packed)) with MinGW stopped working in gcc 4.7.0[3],
>> when -mms-bitfields was turned on by default. This caused the behavior
>> for packing of structs to change, and that in turn caused problems
>> with Soundfonts, where packing is required. As a test, I added
>> "-mno-ms-bitfields" to my Custom.cmake and running the test file I got
>> the correct results.
>>
>> To note: This is *only* an issue on Windows.
>>
>> Now, my concern here is how best to fix this.  I don't know what
>> effects ms-bitfields might have on the rest of the application. My
>> thought is that we only really use packing in the sfont code.  (I'm
>> working on trying to add the flag only when compiling the sfont.c
>> file, hopefully should work!)
>>
>> There is some more information about the ms-bitfields at [4]:
>>
>> [quote]
>>
>> 6.37.3 i386 Type Attributes
>>
>> Two attributes are currently defined for i386 configurations:
>> ms_struct and gcc_struct.
>>
>> ms_structgcc_structIf packed is used on a structure, or if bit-fields
>> are used it may be that the Microsoft ABI packs them differently than
>> GCC normally packs them. Particularly when moving packed data between
>> functions compiled with GCC and the native Microsoft compiler (either
>> via function call or as data in a file), it may be necessary to access
>> either format.
>>
>> Currently -m[no-]ms-bitfields is provided for the Microsoft Windows
>> X86 compilers to match the native Microsoft compiler.
>>
>> [endquote]
>>
>> Once I get this cmake change done, I'll reply here and ask for
>> re-tests on the bug.
>>
>> Thanks!
>> steven
>>
>> [1] - https://sourceforge.net/p/csound/platformspecific/4/
>> [2] - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991
>> [3] - http://gcc.gnu.org/gcc-4.7/changes.html
>> [4] - http://gcc.gnu.org/onlinedocs/gcc-4.8.1/gcc/Type-Attributes.html
>
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
> http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel



--

Oeyvind Brandtsegg
Professor of Music Technology
NTNU
7491 Trondheim
Norway
Cell: +47 92 203 205

http://flyndresang.no/
http://www.partikkelaudio.com/
http://soundcloud.com/brandtsegg
http://soundcloud.com/t-emp

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel