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

WLIB module can not be found for deletion, option -q suppress error/warning messages instead of banner only #1232

Open
Count-MHM opened this issue Feb 10, 2024 · 12 comments

Comments

@Count-MHM
Copy link
Contributor

When wlib is run again without cleaning the last output, it doesn't generate the lib file correctly.

Steps to reproduce:
1. wlib ...
2. change some code
3. wlib ...
4. wlink ...
5. changes have not applied

Minimal, Reproducible Example: Library-Bug.zip

wlib.mp4
wpp386 -zq -fo="Library.cpp.obj" "Library/Library.cpp"
wlib -b -q "Library.lib" +Library.cpp.obj
certutil -hashfile "Library.lib" MD5
MD5 hash of Library.lib:
43118d61bc64e3249632a16d81da894e
CertUtil: -hashfile command completed successfully.
wpp386 -zq -fo="main.cpp.obj" "Program/main.cpp"
wlink option QUIET library { Library.lib } file { main.cpp.obj } name "test.exe"
./test.exe
123

// change 123 to 456 in "Library/Library.cpp"

wpp386 -zq -fo="Library.cpp.obj" "Library/Library.cpp"
wlib -b -q "Library.lib" +Library.cpp.obj
certutil -hashfile "Library.lib" MD5
MD5 hash of Library.lib:
f208d506d63313e6766b32e9eb2fd708
CertUtil: -hashfile command completed successfully.
wpp386 -zq -fo="main.cpp.obj" "Program/main.cpp"
wlink option QUIET library { Library.lib } file { main.cpp.obj } name "test.exe"
./test.exe
123

rm -f "Library.lib"

wpp386 -zq -fo="Library.cpp.obj" "Library/Library.cpp"
wlib -b -q "Library.lib" +Library.cpp.obj
certutil -hashfile "Library.lib" MD5
MD5 hash of Library.lib:
f1f98d7b566cb911f073ef1064f84a2a
CertUtil: -hashfile command completed successfully.
wpp386 -zq -fo="main.cpp.obj" "Program/main.cpp"
wlink option QUIET library { Library.lib } file { main.cpp.obj } name "test.exe"
./test.exe
456

versions used:

Version 2.0 beta Feb  2 2024 00:07:36 (64-bit)
@jmalak
Copy link
Member

jmalak commented Feb 11, 2024

what you are expecting if you use ADD command and module exists in library?
try -+ REPLACE command or no command then REPLACE is default.

  <cmd>       ::= +<object_file_name>                  (add file)
                | +<library_file_name>.lib             (add library)
                | ++<symbol_name>.<DLL_name>[.<export_name>][.<ordinal>]
                | -<module_name>                       (delete)
                | -+<object_file_name>                 (replace)
                | +-<object_file_name>                 (replace)
                | *<module_name>[=<object_file_name>]  (extract)
                | -*<module_name>[=<object_file_name>] (extract and delete)
                | *-<module_name>[=<object_file_name>] (extract and delete)

@jmalak jmalak changed the title WLIB not overwriting old lib file correctly WLIB option -q suppress error/warning messages instead of banner only Feb 11, 2024
@jmalak jmalak added the bug label Feb 11, 2024
@Count-MHM
Copy link
Contributor Author

Doesn't fix it.

wpp386 -zq -fo="Library.cpp.obj" "Library/Library.cpp"
wlib -b -q "Library.lib" -+Library.cpp.obj
certutil -hashfile "Library.lib" MD5
MD5 hash of Library.lib:
81512a56f897c35e5381679a901a5ef7
CertUtil: -hashfile command completed successfully.
wpp386 -zq -fo="main.cpp.obj" "Program/main.cpp"
wlink option QUIET library { Library.lib } file { main.cpp.obj } name "test.exe"
./test.exe
123

// change 123 to 456 in "Library/Library.cpp"

wpp386 -zq -fo="Library.cpp.obj" "Library/Library.cpp"
wlib -b -q "Library.lib" -+Library.cpp.obj
certutil -hashfile "Library.lib" MD5
MD5 hash of Library.lib:
51c20c16069d151e2a4513b2d23497b8
CertUtil: -hashfile command completed successfully.
wpp386 -zq -fo="main.cpp.obj" "Program/main.cpp"
wlink option QUIET library { Library.lib } file { main.cpp.obj } name "test.exe"
./test.exe
123

rm -f "Library.lib"

wpp386 -zq -fo="Library.cpp.obj" "Library/Library.cpp"
wlib -b -q "Library.lib" -+Library.cpp.obj
certutil -hashfile "Library.lib" MD5
MD5 hash of Library.lib:
82af17d61867af198b7a7327700c8619
CertUtil: -hashfile command completed successfully.
wpp386 -zq -fo="main.cpp.obj" "Program/main.cpp"
wlink option QUIET library { Library.lib } file { main.cpp.obj } name "test.exe"
./test.exe
456

@jmalak
Copy link
Member

jmalak commented Feb 11, 2024

I see what problem is.
it is bug for -q option which wrongly suppress error/warning messages.

Anyway replace works for me.

@Count-MHM
Copy link
Contributor Author

Not overwriting the old function when using -+ is the correct behaviour?

Warning! Duplicate symbol 'int __near abc()' ignored.

@jmalak
Copy link
Member

jmalak commented Feb 11, 2024

The main problem for your issue is use " (double quote) for wlink.
Wlink uses single quote that in your case " character is part of name for wlink but not for wlib.

@Count-MHM
Copy link
Contributor Author

Removing double quotes doesn't fix it either.

wpp386 -zq -fo=Library.cpp.obj Library/Library.cpp
wlib -b Library.lib -+Library.cpp.obj
Open Watcom Library Manager
Version 2.0 beta Feb  2 2024 00:01:30 (64-bit)
Copyright (c) 2002-2024 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.
Warning! Cannot open 'Library.lib' - library will be created
certutil -hashfile Library.lib MD5
MD5 hash of Library.lib:
f5c8e69c4e15a5e20bc771e8936e1002
CertUtil: -hashfile command completed successfully.
wpp386 -zq -fo=main.cpp.obj Program/main.cpp
wlink option QUIET library { Library.lib } file { main.cpp.obj } name test.exe
./test.exe
123

// change 123 to 456 in "Library/Library.cpp"

wpp386 -zq -fo=Library.cpp.obj Library/Library.cpp
wlib -b Library.lib -+Library.cpp.obj
Open Watcom Library Manager
Version 2.0 beta Feb  2 2024 00:01:30 (64-bit)
Copyright (c) 2002-2024 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.
Warning! Duplicate symbol 'int __near abc()' ignored.
certutil -hashfile Library.lib MD5
MD5 hash of Library.lib:
b8f3229a40aa07d7edb503e73f171826
CertUtil: -hashfile command completed successfully.
wpp386 -zq -fo=main.cpp.obj Program/main.cpp
wlink option QUIET library { Library.lib } file { main.cpp.obj } name test.exe
./test.exe
123

rm -f Library.lib

wpp386 -zq -fo=Library.cpp.obj Library/Library.cpp
wlib -b Library.lib -+Library.cpp.obj
Open Watcom Library Manager
Version 2.0 beta Feb  2 2024 00:01:30 (64-bit)
Copyright (c) 2002-2024 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.
Warning! Cannot open 'Library.lib' - library will be created       
certutil -hashfile Library.lib MD5
MD5 hash of Library.lib:
0e849e8780b10d129ea82fd2490ad8b4
CertUtil: -hashfile command completed successfully.
wpp386 -zq -fo=main.cpp.obj Program/main.cpp
wlink option QUIET library { Library.lib } file { main.cpp.obj } name test.exe
./test.exe
456

@jmalak
Copy link
Member

jmalak commented Feb 11, 2024

I need to do more investigation, but a problem is caused by internal module name which hold module full path for some reason therefore module is not removed before adding. It looks like old bug, the same behavior with OW 1.9.

@jmalak jmalak changed the title WLIB option -q suppress error/warning messages instead of banner only WLIB module can not be found for deletion, option -q suppress error/warning messages instead of banner only Feb 11, 2024
@jmalak
Copy link
Member

jmalak commented Feb 11, 2024

Please, what host platform you are using?

@Count-MHM
Copy link
Contributor Author

Windows 11 22H2 22621.3007

@Count-MHM
Copy link
Contributor Author

Tested it with another project that was set up to be able to build on WSL, and -+ doesn't work correctly on Linux.

OS: Ubuntu 22.04.3 LTS
Watcom: Version 2.0 beta Jan 1 2024 02:00:25 (64-bit)

@jmalak
Copy link
Member

jmalak commented Feb 11, 2024

The issue is specific for your case. It was reason why it worked for me because I tested wlib as tool without your make file.
The problem is with internal wlib logic how determine module name.
Currently in each OMF module has in THEADER record source file name or module name.
In your case something like ....\Library\Library.cpp that wlib pick "Library" as module name (by removing file extension)
But your module name is like Library.cpp.obj and wlib pick "Library.cpp" as module name (by removing file extension)
therefore wlib cannot found your module in library for deletion.
To fix this issue will require to change module name pickup algorithm.

jmalak added a commit that referenced this issue Feb 11, 2024
it is preparation for adding library/object type field to enable module comparision function change in dependency of type to fix issue #1232
@jmalak jmalak added the WLIB label Feb 13, 2024
jmalak added a commit that referenced this issue Feb 14, 2024
…ssue #1232 )

now comparision metod change in dependency of library format
for OMF objects it compares only base name and try to remove up to two levels of extension
for COFF and ELF objects it compares base name with extension
@jmalak
Copy link
Member

jmalak commented Feb 14, 2024

now the problem with removing the module in the library with "multiple" extensions in your names should be fixed
the problem with the -q option and suppressed messages will be fixed later

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

No branches or pull requests

2 participants