Bug 569872 - [GTK] compilation error using DEBUG_CALL_PRINTS
Summary: [GTK] compilation error using DEBUG_CALL_PRINTS
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.18   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.19 M1   Edit
Assignee: Sravan Kumar Lakkimsetti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-22 06:55 EST by Andrey Loskutov CLA
Modified: 2021-01-07 01:38 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Loskutov CLA 2020-12-22 06:55:24 EST
Open /org.eclipse.swt/Eclipse SWT/common/library/callback.c
Uncomment #define DEBUG_CALL_PRINTS
cd org.eclipse.swt/bin/library
make clean ; ./build.sh -gtk3 install

./build.sh clean
Cairo found, compiling SWT support for the cairo graphics library.
libjawt.so found, the SWT/AWT integration library will be compiled.
Cleaning up...
make[1]: Entering directory `/data/4x_platform_workspace/eclipse.platform.swt/bundles/org.eclipse.swt/bin/library'
rm -f *.o *.so
make[1]: Leaving directory `/data/4x_platform_workspace/eclipse.platform.swt/bundles/org.eclipse.swt/bin/library'
Cairo found, compiling SWT support for the cairo graphics library.
libjawt.so found, the SWT/AWT integration library will be compiled.
Building SWT/GTK+ for Architectures: linux x86_64
Building GTK3 bindings:
gcc -O -Wall -fPIC -DSWT_VERSION=4942r5    -DLINUX -DGTK -I/usr/lib/jvm/java-11/include -I/usr/lib/jvm/java-11/include/linux -DJNI64 -c swt.c
gcc -O -Wall -fPIC -DSWT_VERSION=4942r5    -DLINUX -DGTK -I/usr/lib/jvm/java-11/include -I/usr/lib/jvm/java-11/include/linux -DJNI64   -c -o c.o c.c
gcc -O -Wall -fPIC -DSWT_VERSION=4942r5    -DLINUX -DGTK -I/usr/lib/jvm/java-11/include -I/usr/lib/jvm/java-11/include/linux -DJNI64   -c -o c_stats.o c_stats.c
gcc -O -Wall -fPIC -DSWT_VERSION=4942r5    -DLINUX -DGTK -I/usr/lib/jvm/java-11/include -I/usr/lib/jvm/java-11/include/linux -DJNI64 `pkg-config --cflags gtk+-3.0 gtk+-unix-print-3.0` -DUSE_ASSEMBLER -c callback.c
callback.c: In function 'callback':
callback.c:1252:3: error: 'for' loop initial declarations are only allowed in C99 mode
   for (int i=0; i<argCount; i++) {
   ^
callback.c:1252:3: note: use option -std=c99 or -std=gnu99 to compile your code
make: *** [callback.o] Error 1
*** GTK3 Build failed, aborting further actions..

Note: adding -std=c99 to the build.sh makes the compiler happy, but the resulting SWT library crashes if trying to open native File dialog, see bug 569853 comment 13.

So the reverse patch https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/174052/1/bundles/org.eclipse.swt/Eclipse+SWT+PI/gtk/library/build.sh is not an option.
Comment 1 Alexandr Miloslavskiy CLA 2020-12-22 07:05:48 EST
Instead of just reverting the patch, it would be nice to figure the cause of the crash. I really doubt that compiler is to be blamed, rather I expect that it shuffled something a bit and uncovered some problem in SWT.

I could do that... next year, haha, once I'm back from vacation. However, it would be nice if someone does it earlier :)
Comment 2 Eclipse Genie CLA 2020-12-22 07:58:27 EST
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/174056
Comment 3 Sravan Kumar Lakkimsetti CLA 2020-12-22 08:01:00 EST
The code is in C. So you need to define all the variables at the start of a code block. 

Defining i at the start of the block should suffice for this problem instead of using -std=c99 flag. 

Attaching a patch now. 

@Andrey

Can you check the patch whether you are getting any compilation errors?
Comment 4 Andrey Loskutov CLA 2020-12-22 08:08:25 EST
(In reply to Alexandr Miloslavskiy from comment #1)
> Instead of just reverting the patch, it would be nice to figure the cause of
> the crash. 

I have no real C knowledge to pinpoint some compiler issues, so fixing a build was priority #1 for me.

(In reply to Eclipse Genie from comment #2)
> New Gerrit change created:
> https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/174056

Sravan has the solution, and I would never in life assume this change can cause C compiler error :-)

(In reply to Sravan Kumar Lakkimsetti from comment #3)
> 
> Can you check the patch whether you are getting any compilation errors?

Thanks Sravan, unbelievable, it works fine with this change... I'm happy we have Java for the rest of the code :-)
Comment 5 Andrey Loskutov CLA 2020-12-22 08:16:52 EST
(In reply to Alexandr Miloslavskiy from comment #1)
> Instead of just reverting the patch, it would be nice to figure the cause of
> the crash. I really doubt that compiler is to be blamed, rather I expect
> that it shuffled something a bit and uncovered some problem in SWT.

I've created bug 569874 for the crash.
Comment 7 Alexandr Miloslavskiy CLA 2020-12-22 08:29:03 EST
OK, I'll have a look later.
Comment 8 Sravan Kumar Lakkimsetti CLA 2020-12-23 21:26:16 EST
Resolving now
Comment 9 Sravan Kumar Lakkimsetti CLA 2021-01-07 01:38:45 EST
Verified in Eclipse SDK
Version: 2021-03 (4.19)
Build id: I20210105-1800
OS: Linux, v.5.4.0-59-generic, x86_64 / gtk 3.24.20
Java version: 11.0.9.1