Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct cmake script to support Open Watcom toolchain #8167

Closed
wants to merge 2 commits into from

Conversation

jmalak
Copy link

@jmalak jmalak commented Nov 8, 2024

Description

CMake build by Open Watcom toolchain failed due to -Wall option
Open Watcom doesn't support -Wall option it uses -wx instead
-wcd=202 option suppress message about unreferenced functions

Testing

Run WolfSSL CMake build with Open Watcom toolchain
It will not report incorrect -Wall option

@wolfSSL-Bot
Copy link

Can one of the admins verify this patch?

@dgarske
Copy link
Contributor

dgarske commented Nov 8, 2024

Hi @jmalak ,

Can you tell us more about your project and interest in our library? I recently worked with a customer for Watcom-C compiler support, but I did not try it with CMake.

We do require a contributor agreement to be in place to accept code changes. We could treat this as a bug report if that becomes an issue. Are you planning additional pull requests?

Thanks, David Garske, wolfSSL

@jmalak
Copy link
Author

jmalak commented Nov 8, 2024

Hi @jmalak ,

Can you tell us more about your project and interest in our library? I recently worked with a customer for Watcom-C compiler support, but I did not try it with CMake.

The main interest is to compile WolfSSL by Open Watcom toolchain, because OpenSSL is too much non-standard and requires many patches to do it working with Open Watcom. I thing that WolfSSL is more suitable to port to Open Watcom with much smaller number of changes. It should enable Open Watcom users to use WolfSSL for theirs applications. Main interest is build for Linux/Windows/OS/2 targets.
Because Open Watcom make system is different from Microsoft an GNU, existing WolfSSL make files can not be used for Open Watcom build without big changes.
Therefore simplest method to build WolfSSL is to use WolfSSL CMake support because Open Watcom toolchain is fully supported by CMake for all target OSEs (Linux/Windows/OS/2 and others).

We do require a contributor agreement to be in place to accept code changes. We could treat this as a bug report if that becomes an issue. Are you planning additional pull requests?

Yes I am planning to do more pull requests because in WolfSSL are some incompatibilities with Open Watcom which will requires small changes by example for Windows thread support.

Please If you need some agreement then give me some link to info how to process.
Thanks
Jiri Malak

@dgarske
Copy link
Contributor

dgarske commented Nov 8, 2024

Hi @jmalak ,

That's wonderful! To start the process of becoming an approved contributor please email [email protected] and refernce a link to this PR and include your country of residence.

Thanks,
David Garske, wolfSSL

@jmalak jmalak force-pushed the cmake branch 7 times, most recently from 6acec23 to 09f3718 Compare November 9, 2024 06:34
@jmalak
Copy link
Author

jmalak commented Nov 9, 2024

Sorry, I put some WIP into this branch. Now it is corrected.

@kareem-wolfssl
Copy link
Contributor

ok to test

@bandi13
Copy link
Contributor

bandi13 commented Nov 12, 2024

retest this please

Open Watcom doesn't support -Wall it uses -wx instead
-wcd=202 suppress message about unreferenced functions
@jmalak
Copy link
Author

jmalak commented Jan 25, 2025

It's been sitting here without a review for over a month.
If you're not interested, I'd assume someone will write why it wasn't accepted.
Now it seems like there's no point in contributing to WolfSSL if there's no interest.

@dgarske dgarske self-assigned this Jan 26, 2025
@dgarske
Copy link
Contributor

dgarske commented Jan 26, 2025

Hi @jmalak ,

Thank you for the reminder on this. I checked and you are an approved contributor. I will personally review this on Monday.

Thanks,
David Garske, wolfSSL

@dgarske
Copy link
Contributor

dgarske commented Jan 27, 2025

Jenkins... retest this please: Failure was NOT related to this PR "FIPSv2-regression"

@dgarske
Copy link
Contributor

dgarske commented Jan 27, 2025

Hi @jmalak ,

We should be able to get these PR's merged quickly, but I would like to run some tests.

Can you please share the example cmake command line you used for building wolfSSL with open watcom? I've tried a few things.

$ which wcc
/usr/bin/watcom/binl64/wcc

$ wcc --version
Open Watcom C x86 16-bit Optimizing Compiler
Version 2.0 beta Jan  3 2025 02:14:49 (64-bit)
Copyright (c) 2002-2025 The Open Watcom Contributors. All Rights Reserved.
Portions Copyright (c) 1984-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See https://github.com/open-watcom/open-watcom-v2#readme for details.
Error! Unable to open 'ersion.c'

$ cmake -B build -S . \
      -DCMAKE_SYSTEM_NAME=Generic \
      -DCMAKE_C_COMPILER=wcc \
      -DCMAKE_CXX_COMPILER=wpp \
      -DCMAKE_ASM_COMPILER=wasm \
      -DCMAKE_AR=wlib
-- The C compiler identification is OpenWatcom 2.0
-- The ASM compiler identification is unknown
-- Found assembler: /usr/bin/watcom/binl64/wasm
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/bin/watcom/binl64/wcc
-- Check for working C compiler: /usr/bin/watcom/binl64/wcc - broken
CMake Error at /usr/share/cmake-3.28/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "/usr/bin/watcom/binl64/wcc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: '/home/davidgarske/GitHub/wolfssl/build/CMakeFiles/CMakeScratch/TryCompile-X0mtij'
    
    Run Build Command(s): /usr/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f Makefile cmTC_51378/fast
    /usr/bin/gmake  -f CMakeFiles/cmTC_51378.dir/build.make CMakeFiles/cmTC_51378.dir/build
    gmake[1]: Entering directory '/home/davidgarske/GitHub/wolfssl/build/CMakeFiles/CMakeScratch/TryCompile-X0mtij'
    Building C object CMakeFiles/cmTC_51378.dir/testCCompiler.c.obj
    /usr/bin/watcom/binl64/wcc -zq -d+   -w3  -foCMakeFiles/cmTC_51378.dir/testCCompiler.c.obj -c -cc /home/davidgarske/GitHub/wolfssl/build/CMakeFiles/CMakeScratch/TryCompile-X0mtij/testCCompiler.c
    Open Watcom C x86 16-bit Optimizing Compiler
    Version 2.0 beta Jan  3 2025 02:14:49 (64-bit)
    Copyright (c) 2002-2025 The Open Watcom Contributors. All Rights Reserved.
    Portions Copyright (c) 1984-2002 Sybase, Inc. All Rights Reserved.
    Source code is available under the Sybase Open Watcom Public License.
    See https://github.com/open-watcom/open-watcom-v2#readme for details.
    Error! E1139: Command line contains more than one file to compile
    Error! E1139: Command line contains more than one file to compile
    gmake[1]: *** [CMakeFiles/cmTC_51378.dir/build.make:78: CMakeFiles/cmTC_51378.dir/testCCompiler.c.obj] Error 1
    gmake[1]: Leaving directory '/home/davidgarske/GitHub/wolfssl/build/CMakeFiles/CMakeScratch/TryCompile-X0mtij'
    gmake: *** [Makefile:127: cmTC_51378/fast] Error 2
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:37 (project)


-- Configuring incomplete, errors occurred!

Thanks,
David Garske, wolfSSL

@jmalak
Copy link
Author

jmalak commented Jan 28, 2025

Hi @dgarske,

I am not sure what is best method to check it.
It looks like you use Linux host for testing.
You have configured Open Watcom because you can run 16-bit compiler.

Create build subdirectory to have separated build objects from WolfSSL tree.

Then you can use following cmake command to configure WolfSSL in CMake for Open Watcom

cmake -B build -G "Watcom WMake" -D CMAKE_VERBOSE_MAKEFILE=TRUE -D CMAKE_SYSTEM_NAME=linux -D CMAKE_SYSTEM_PROCESSOR=x86 -D WOLFSSL_ASM=no -DCMAKE_BUILD_TYPE=Release

Next you can run build.

Regards

Jiri

@dgarske
Copy link
Contributor

dgarske commented Jan 28, 2025

Hi @jmalak ,

Again thank you so much for these PR's. I am getting further, but now getting a linker error:

/home/davidgarske/GitHub/wolfssl/src/tls13.c: 15029 lines, included 138248, 0 warnings, 0 errors
Code size: 21849
[ 90%] Linking C shared library libwolfssl.so
/usr/bin/cmake -E cmake_link_script CMakeFiles/wolfssl.dir/link.txt --verbose=1
/usr/bin/watcom/binl64/wlink  name libwolfssl.so opt map option implib="" file {CMakeFiles/wolfssl.dir/wolfcrypt/src/hmac.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/hash.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/cpuid.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/kdf.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/random.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/sha256.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/rsa.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/sp_int.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/aes.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/sha.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/sha512.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/logging.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/wc_port.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/error.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/wc_encrypt.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/signature.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/wolfmath.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/memory.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/dh.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/asn.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/coding.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/poly1305.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/md5.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/pwdbased.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/pkcs12.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/chacha.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/chacha20_poly1305.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/misc.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/integer.c.obj CMakeFiles/wolfssl.dir/wolfcrypt/src/ecc.c.obj CMakeFiles/wolfssl.dir/src/internal.c.obj CMakeFiles/wolfssl.dir/src/wolfio.c.obj CMakeFiles/wolfssl.dir/src/keys.c.obj CMakeFiles/wolfssl.dir/src/ssl.c.obj CMakeFiles/wolfssl.dir/src/ocsp.c.obj CMakeFiles/wolfssl.dir/src/tls.c.obj CMakeFiles/wolfssl.dir/src/tls13.c.obj}  library m 
Open Watcom Linker Version 2.0 beta Jan  3 2025 02:12:20 (64-bit)
Copyright (c) 2002-2025 The Open Watcom Contributors. All Rights Reserved.
Portions Copyright (c) 1985-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See https://github.com/open-watcom/open-watcom-v2#readme for details.
Error! E3033: directive error near '{CMakeFiles/wolfssl.dir/wolfcrypt/src/hmac.c.obj'
Error(E42): Last command making (libwolfssl.so) returned a bad status
Error(E02): Make execution terminated
Error(E42): Last command making (CMakeFiles/wolfssl.dir/all) returned a bad status
Error(E02): Make execution terminated
Error(E42): Last command making (all) returned a bad status
Error(E02): Make execution terminated

watcom.patch
WatcomC.txt

Any ideas for how to solve that?

The end result of this will be a new CI test for Watcom C.

Thanks,
David Garske, wolfSSL

@jmalak
Copy link
Author

jmalak commented Jan 28, 2025

This is only the first step that is necessary, but it does not mean that the compilation will be successful. This issue blocked start compilation by Open Watcom toolchain at all with CMake.
Now I will continue to identify problems in the C source code and fix them.

I have a second PR #8175 with a thread launch fix that solves the issue with Open Watcom calling convention for thread start function and the problem with the function never returning.

I try to proceed with smaller changes rather than making a big bang (all in one change). It is simpler for me to learn WolfSSL codebase gradually.

Anyway I found out one mistake in Open Watcom compiler preprocessor which first need to fix.

Regards

Jiri

@jmalak
Copy link
Author

jmalak commented Jan 28, 2025

Oh sorry, I primary works on Windows version now that Linux version can have different issue due to POSIX thread implementation.
Windows version is our primary target, next will be Linux and OS/2.

The best is test Windows build, you can do it on Linux by CMake command

cmake -B build -G "Watcom WMake" -D CMAKE_VERBOSE_MAKEFILE=TRUE -D CMAKE_SYSTEM_NAME=Windows -D CMAKE_SYSTEM_PROCESSOR=x86 -D WOLFSSL_ASM=no -DCMAKE_BUILD_TYPE=Release

Open Watcom cross-compilation is fully supported by CMake that you can build also on Windows for Linux etc.

Jiri

@jmalak
Copy link
Author

jmalak commented Jan 28, 2025

To the issue with linker is due to Open Watcom doesn't support shared libraries on Linux yet, it should be configured for linux to use static libraries. For Windows target it should not be a problem the DLL is fully supported.

dgarske added a commit to dgarske/wolfssl that referenced this pull request Jan 28, 2025
* Correct cmake script to support Open Watcom toolchain (wolfSSL#8167)
* Fix thread start callback prototype for Open Watcom toolchain (wolfSSL#8175)
* Added GitHub CI action
dgarske added a commit to dgarske/wolfssl that referenced this pull request Jan 28, 2025
* Correct cmake script to support Open Watcom toolchain (wolfSSL#8167)
* Fix thread start callback prototype for Open Watcom toolchain (wolfSSL#8175)
* Added GitHub CI action
dgarske added a commit to dgarske/wolfssl that referenced this pull request Jan 28, 2025
* Correct cmake script to support Open Watcom toolchain (wolfSSL#8167)
* Fix thread start callback prototype for Open Watcom toolchain (wolfSSL#8175)
* Added GitHub CI action
dgarske added a commit to dgarske/wolfssl that referenced this pull request Jan 28, 2025
* Correct cmake script to support Open Watcom toolchain (wolfSSL#8167)
* Fix thread start callback prototype for Open Watcom toolchain (wolfSSL#8175)
* Added GitHub CI action
dgarske added a commit to dgarske/wolfssl that referenced this pull request Jan 28, 2025
* Correct cmake script to support Open Watcom toolchain (wolfSSL#8167)
* Fix thread start callback prototype for Open Watcom toolchain (wolfSSL#8175)
* Added GitHub CI action
dgarske added a commit to dgarske/wolfssl that referenced this pull request Jan 28, 2025
* Correct cmake script to support Open Watcom toolchain (wolfSSL#8167)
* Fix thread start callback prototype for Open Watcom toolchain (wolfSSL#8175)
* Added GitHub CI action
dgarske added a commit to dgarske/wolfssl that referenced this pull request Jan 28, 2025
* Correct cmake script to support Open Watcom toolchain (wolfSSL#8167)
* Fix thread start callback prototype for Open Watcom toolchain (wolfSSL#8175)
* Added GitHub CI action
dgarske added a commit to dgarske/wolfssl that referenced this pull request Jan 28, 2025
* Correct cmake script to support Open Watcom toolchain (wolfSSL#8167)
* Fix thread start callback prototype for Open Watcom toolchain (wolfSSL#8175)
* Added GitHub CI action
dgarske added a commit to dgarske/wolfssl that referenced this pull request Jan 28, 2025
* Correct cmake script to support Open Watcom toolchain (wolfSSL#8167)
* Fix thread start callback prototype for Open Watcom toolchain (wolfSSL#8175)
* Added GitHub CI action
dgarske added a commit to dgarske/wolfssl that referenced this pull request Jan 29, 2025
* Correct cmake script to support Open Watcom toolchain (wolfSSL#8167)
* Fix thread start callback prototype for Open Watcom toolchain (wolfSSL#8175)
* Added GitHub CI action
dgarske added a commit to dgarske/wolfssl that referenced this pull request Jan 29, 2025
* Correct cmake script to support Open Watcom toolchain (wolfSSL#8167)
* Fix thread start callback prototype for Open Watcom toolchain (wolfSSL#8175)
* Added GitHub CI action
dgarske added a commit to dgarske/wolfssl that referenced this pull request Jan 29, 2025
* Correct cmake script to support Open Watcom toolchain (wolfSSL#8167)
* Fix thread start callback prototype for Open Watcom toolchain (wolfSSL#8175)
* Added GitHub CI action
dgarske added a commit to dgarske/wolfssl that referenced this pull request Jan 29, 2025
* Correct cmake script to support Open Watcom toolchain (wolfSSL#8167)
* Fix thread start callback prototype for Open Watcom toolchain (wolfSSL#8175)
* Added GitHub CI action
dgarske added a commit to dgarske/wolfssl that referenced this pull request Jan 29, 2025
* Correct cmake script to support Open Watcom toolchain (wolfSSL#8167)
* Fix thread start callback prototype for Open Watcom toolchain (wolfSSL#8175)
* Added GitHub CI action
dgarske added a commit to dgarske/wolfssl that referenced this pull request Jan 29, 2025
* Correct cmake script to support Open Watcom toolchain (wolfSSL#8167)
* Fix thread start callback prototype for Open Watcom toolchain (wolfSSL#8175)
* Added GitHub CI action
@dgarske
Copy link
Contributor

dgarske commented Jan 29, 2025

Closing in favor of #8391

@dgarske dgarske closed this Jan 29, 2025
dgarske added a commit to dgarske/wolfssl that referenced this pull request Jan 30, 2025
* Correct cmake script to support Open Watcom toolchain (wolfSSL#8167)
* Fix thread start callback prototype for Open Watcom toolchain (wolfSSL#8175)
* Added GitHub CI action
dgarske added a commit to dgarske/wolfssl that referenced this pull request Jan 31, 2025
* Correct cmake script to support Open Watcom toolchain (wolfSSL#8167)
* Fix thread start callback prototype for Open Watcom toolchain (wolfSSL#8175)
* Added GitHub CI action
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants